@gutenye/script.js 2.7.1 → 2.7.3
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/package.json +1 -1
- package/src/Command.ts +1 -1
- package/src/ake/completions/ake.fish +5 -1
- package/src/ake/shared.ts +1 -1
- package/src/completion.ts +3 -2
- package/src/frequent-used-helpers.ts +4 -2
package/package.json
CHANGED
package/src/Command.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function _setup_ake_complete
|
|
2
2
|
set cmd $argv[1]
|
|
3
|
-
set
|
|
3
|
+
if set -q argv[2]
|
|
4
|
+
set suffix $argv[2]
|
|
5
|
+
else
|
|
6
|
+
set suffix ''
|
|
7
|
+
end
|
|
4
8
|
complete --erase $cmd$suffix
|
|
5
9
|
complete --command $cmd$suffix --no-files --arguments "(_ake_complete $suffix)"
|
|
6
10
|
end
|
package/src/ake/shared.ts
CHANGED
package/src/completion.ts
CHANGED
|
@@ -2,8 +2,8 @@ import fsSync from 'node:fs'
|
|
|
2
2
|
import os from 'node:os'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import * as yaml from 'yaml'
|
|
5
|
-
import type { Command } from './Command'
|
|
6
5
|
import { getAkeSuffix, getCompletionName } from './ake/shared'
|
|
6
|
+
import type { Command } from './Command'
|
|
7
7
|
|
|
8
8
|
export type CompletionValue = string[] | (() => string[])
|
|
9
9
|
|
|
@@ -60,11 +60,12 @@ export function buildSpec(command: Command): CarapaceSpec {
|
|
|
60
60
|
for (const opt of command.options) {
|
|
61
61
|
spec.flags = spec.flags || {}
|
|
62
62
|
let flag = [opt.short, opt.long].filter(Boolean).join(', ')
|
|
63
|
+
const values = resolveCompletion(opt.completion)
|
|
63
64
|
if (opt.required) flag += '='
|
|
64
65
|
else if (opt.optional) flag += '=?'
|
|
66
|
+
else if (values.length > 0) flag += '='
|
|
65
67
|
spec.flags[flag] = opt.description
|
|
66
68
|
|
|
67
|
-
const values = resolveCompletion(opt.completion)
|
|
68
69
|
if (values.length > 0) {
|
|
69
70
|
completion.flag = completion.flag || {}
|
|
70
71
|
const key = opt.long?.replace(/^--/, '') || opt.attributeName
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export function exitWithError(message: string, help?: string) {
|
|
1
|
+
export function exitWithError(message: string, help?: string): never {
|
|
2
2
|
console.error(`\nError: ${message}`)
|
|
3
|
-
if (help)
|
|
3
|
+
if (help) {
|
|
4
|
+
console.log(`\n${help}`)
|
|
5
|
+
}
|
|
4
6
|
process.exit(1)
|
|
5
7
|
}
|