@jutge.org/toolkit 4.2.28 → 4.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -230,6 +230,7 @@ jtk make # Build all problem elements
230
230
  jtk verify <program> # Test a solution
231
231
  jtk upload # Upload to Jutge.org
232
232
  jtk clean # Clean temporary files
233
+ jtk passcode # Manage problem passcode
233
234
 
234
235
  jtk doctor # Check system dependencies
235
236
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jutge.org/toolkit",
3
3
  "description": "Toolkit to prepare problems for Jutge.org",
4
- "version": "4.2.28",
4
+ "version": "4.2.30",
5
5
  "homepage": "https://jutge.org",
6
6
  "author": {
7
7
  "name": "Jutge.org",
package/toolkit/index.ts CHANGED
@@ -18,6 +18,7 @@ import { makeCmd } from './make'
18
18
  import { quizCmd } from './quiz'
19
19
  import { upgradeCmd } from './upgrade'
20
20
  import { uploadCmd } from './upload'
21
+ import { cmdPasscode } from './passcode'
21
22
  import { askCmd } from './ask'
22
23
  import { convertCmd } from './convert'
23
24
  import { stageCmd } from './stage'
@@ -31,6 +32,7 @@ program.addHelpText('after', '\nMore documentation:\n https://github.com/jutge-
31
32
 
32
33
  program.addCommand(makeCmd)
33
34
  program.addCommand(uploadCmd)
35
+ program.addCommand(cmdPasscode)
34
36
  program.addCommand(cleanCmd)
35
37
  program.addCommand(cloneCmd)
36
38
  program.addCommand(generateCmd)
@@ -0,0 +1,41 @@
1
+ import { Command } from '@commander-js/extra-typings'
2
+ import { removePasscodeInDirectory, setPasscodeInDirectory, showPasscodeInDirectory } from '../lib/passcode'
3
+
4
+ export const cmdPasscode = new Command('passcode')
5
+ .summary('Show, set or remove problem passcode')
6
+ .description(
7
+ `Show, set or remove the passcode of a problem at Jutge.org.
8
+
9
+ These operations require an existing problem.yml file in the problem directory.
10
+ On success, problem.yml is updated with the new passcode (or empty for remove).`,
11
+ )
12
+
13
+
14
+ cmdPasscode
15
+ .command('show')
16
+ .description('Show the passcode of the problem')
17
+ .option('-d, --directory <directory>', 'problem directory', '.')
18
+
19
+ .action(async ({ directory }) => {
20
+ await showPasscodeInDirectory(directory)
21
+ })
22
+
23
+ cmdPasscode
24
+ .command('set')
25
+ .description('Set or update the passcode of the problem')
26
+
27
+ .option('-d, --directory <directory>', 'problem directory', '.')
28
+ .option('-p, --passcode <passcode>', 'passcode (if omitted, will prompt)')
29
+
30
+ .action(async ({ directory, passcode }) => {
31
+ await setPasscodeInDirectory(directory, passcode)
32
+ })
33
+
34
+ cmdPasscode
35
+ .command('remove')
36
+ .description('Remove the passcode of the problem')
37
+ .option('-d, --directory <directory>', 'problem directory', '.')
38
+
39
+ .action(async ({ directory }) => {
40
+ await removePasscodeInDirectory(directory)
41
+ })