-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chapman Pendery <[email protected]>
- Loading branch information
Showing
6 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Command } from "commander"; | ||
import { loadConfig } from "../../utils/config.js"; | ||
import { getSpecNames, loadLocalSpecsSet } from "../../runtime/runtime.js"; | ||
import { getAliasNames, loadAliases } from "../../runtime/alias.js"; | ||
import { aliasSupportedShells, Shell } from "../../utils/shell.js"; | ||
|
||
const supportedShells = aliasSupportedShells.join(", "); | ||
|
||
type ListCommandOptions = { | ||
shell: Shell | undefined; | ||
}; | ||
|
||
const action = (program: Command) => async (options: ListCommandOptions) => { | ||
await loadConfig(program); | ||
await loadLocalSpecsSet(); | ||
|
||
const { shell } = options; | ||
if (shell && !aliasSupportedShells.map((s) => s.valueOf()).includes(shell)) { | ||
program.error(`Unsupported shell: '${shell}', supported shells: ${supportedShells}`, { exitCode: 1 }); | ||
} | ||
if (shell) { | ||
await loadAliases(shell); | ||
} | ||
process.stdout.write(JSON.stringify([...getAliasNames(), ...getSpecNames()])); | ||
process.exit(0); | ||
}; | ||
|
||
const cmd = new Command("list"); | ||
cmd.description(`list the names of all available specs`); | ||
cmd.option("-s, --shell <shell>", `shell to use alias specs, supported shells: ${supportedShells}`); | ||
cmd.action(action(cmd)); | ||
|
||
export default cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Command } from "commander"; | ||
import list from "./list.js"; | ||
|
||
const cmd = new Command("specs"); | ||
cmd.description(`manage specs`); | ||
cmd.addCommand(list); | ||
|
||
export default cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters