@jutge.org/toolkit 4.4.16 → 4.4.17

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.
package/toolkit/quiz.ts CHANGED
@@ -1,44 +1,52 @@
1
1
  import { Command } from '@commander-js/extra-typings'
2
- import { makeQuiz, validateQuiz } from '../lib/quiz'
2
+ import { runQuiz, lintQuiz } from '../lib/quiz'
3
3
  import tui from '../lib/tui'
4
4
  import { findRealDirectories } from '../lib/helpers'
5
5
  import { random } from 'radash'
6
6
 
7
7
  export const quizCmd = new Command('quiz')
8
- .description('Commands related to quizzes')
8
+ .summary('Commands related to quizzes')
9
9
 
10
10
  .action(() => {
11
11
  quizCmd.help()
12
12
  })
13
13
 
14
14
  quizCmd
15
- .command('validate')
16
- .description('Validate a quiz problem')
15
+ .command('lint')
16
+ .summary('Lint a quiz problem')
17
17
 
18
18
  .option('-d, --directory <directory>', 'problem directory', '.')
19
19
 
20
20
  .action(async ({ directory }) => {
21
21
  const realDirectories = await findRealDirectories([directory])
22
22
  for (const directory of realDirectories) {
23
- await tui.section(`Validating quiz in directory ${tui.hyperlink(directory)}`, async () => {
24
- await validateQuiz(directory)
23
+ await tui.section(`Linting quiz in directory ${tui.hyperlink(directory)}`, async () => {
24
+ await lintQuiz(directory)
25
25
  })
26
26
  }
27
27
  })
28
28
 
29
29
  quizCmd
30
- .command('make')
31
- .description('Make a quiz problem')
30
+ .command('run')
31
+ .summary('Run a quiz problem')
32
+ .description(
33
+ `Run a quiz problem. This command is work-in-progress and may not work as expected yet.
34
+
35
+ This command will run the quiz problem and print the resulting object to stdout.
36
+ A random seed will be generated if not provided.
37
+ `,
38
+ )
32
39
 
33
40
  .option('-d, --directory <directory>', 'problem directory', '.')
34
41
  .option('-s, --seed <seed>', 'random seed')
42
+ .option('-f, --format <format>', 'output format (json|yaml)', 'json')
35
43
 
36
- .action(async ({ directory, seed }) => {
37
- tui.warning('The quiz make command is work-in-progress and may not work as expected yet.')
38
- const realDirectories = await findRealDirectories([directory])
44
+ .action(async ({ directory, seed, format }) => {
39
45
  const seedValue = seed ? parseInt(seed, 10) : random(1000000, 9999999)
40
- for (const directory of realDirectories) {
41
- await makeQuiz(directory, seedValue)
42
- return // in this case we only process one directory as quizzes should only have one language
46
+ const object = await runQuiz(directory, seedValue)
47
+ if (format === 'json') {
48
+ tui.json(object)
49
+ } else {
50
+ tui.yaml(object)
43
51
  }
44
52
  })
package/toolkit/share.ts CHANGED
@@ -2,11 +2,11 @@ import { password } from '@inquirer/prompts'
2
2
  import { Command } from '@commander-js/extra-typings'
3
3
  import { updateSharingSettings } from '../lib/share'
4
4
 
5
-
6
5
  export const cmdShare = new Command('share')
7
6
  .summary('Update and show sharing settings')
8
7
 
9
- .description(`Update and show sharing settings
8
+ .description(
9
+ `Update and show sharing settings
10
10
 
11
11
  First, this command updates the sharing settings in problem.yml file with the ones on Jutge.org to ensure they are consistent.
12
12
 
@@ -18,7 +18,8 @@ Then, it updates the sharing settings in Jutge.org with the requested changes. T
18
18
  --solutions Share solutions
19
19
  --no-solutions Stop sharing solutions
20
20
 
21
- Finally, it updates problem.yml file with the current sharing settings and shows them.`)
21
+ Finally, it updates problem.yml file with the current sharing settings and shows them.`,
22
+ )
22
23
 
23
24
  .option('-d, --directory <directory>', 'problem directory', '.')
24
25
  .option('--passcode [code]', 'Set a passcode (prompted if omitted)')
@@ -46,4 +47,4 @@ Finally, it updates problem.yml file with the current sharing settings and shows
46
47
  const solutions = this.getOptionValueSource('solutions') !== 'default' ? opts.solutions : undefined
47
48
 
48
49
  await updateSharingSettings(opts.directory, { passcode, testcases, solutions })
49
- })
50
+ })
package/toolkit/submit.ts CHANGED
@@ -10,7 +10,10 @@ export const submitCmd = new Command('submit')
10
10
  .option('-c, --compiler <id>', 'compiler to use (default: auto-detect from file extension)', 'auto')
11
11
  .option('-l, --language <code>', 'language code (ca, es, en, ...)', 'en')
12
12
  .option('-n, --no-wait', 'do not wait for submissions to be judged')
13
- .option('--no-browser', 'do not open the submission URL in the browser (only print URL and/or wait for verdict in terminal)')
13
+ .option(
14
+ '--no-browser',
15
+ 'do not open the submission URL in the browser (only print URL and/or wait for verdict in terminal)',
16
+ )
14
17
  .option('-a, --annotation <annotation>', "annotation for the submission (default: 'jtk-submit-<nanoid16>')")
15
18
 
16
19
  .action(async (programs, { directory, compiler, language, wait, browser, annotation }) => {