Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcd8057

Browse files
committed
use version
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentd53c378 commitbcd8057

File tree

3 files changed

+34
-64
lines changed

3 files changed

+34
-64
lines changed

‎package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"@coderoad/cli",
3-
"version":"0.0.3",
3+
"version":"0.0.4",
44
"description":"A CLI to build the configuration file for Coderoad Tutorials",
55
"main":"src/main.js",
66
"bin": {

‎src/cli.ts

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type ParsedArgs = {
1818
setupBranch:string;
1919
output?:string;
2020
help:string;
21+
version?:string;
2122
};
2223

2324
typeOptions={
@@ -31,37 +32,6 @@ type Options = {
3132
constlocalGit="Local directory";
3233
constremoteGit="Git remote address";
3334

34-
functionparseArgumentsIntoOptions(rawArgs:string[]):ParsedArgs{
35-
constargs=arg(
36-
{
37-
"--git":String,
38-
"--dir":String,
39-
"--code":String,
40-
"--setup":String,
41-
"--output":String,
42-
"--help":Boolean,
43-
"-g":"--git",
44-
"-d":"--dir",
45-
"-c":"--code",
46-
"-s":"--setup",
47-
"-o":"--output",
48-
"-h":"--help",
49-
},
50-
{
51-
argv:rawArgs.slice(2),
52-
}
53-
);
54-
return{
55-
command:args["_"][0],
56-
git:args["--git"],
57-
dir:args["--dir"],
58-
codeBranch:args["--code"],
59-
setupBranch:args["--setup"],
60-
output:args["--output"]||"./config.json",
61-
help:args["--help"]||false,
62-
};
63-
}
64-
6535
exportasyncfunctionpromptForMissingOptions(
6636
options:ParsedArgs
6737
):Promise<Options>{
@@ -152,36 +122,36 @@ export async function promptForMissingOptions(
152122
}
153123

154124
exportasyncfunctioncli(args:string[]):Promise<void>{
155-
letparsedArgs:ParsedArgs=parseArgumentsIntoOptions(args);
156-
157-
// If help called just print the help text and exit
158-
if(parsedArgs.help){
159-
console.log(
160-
"Docs can be found at github: https://github.com/coderoad/coderoad-cli/"
161-
);
162-
}elseif(!parsedArgs.command){
163-
console.log(
164-
`The command is missing. Choose either 'create' or 'build' and itsoptions.`
165-
);
166-
}else{
167-
switch(parsedArgs.command){
168-
case"build":
169-
//Otherwise, continue with the otheroptions
170-
constoptions:BuildOptions=awaitpromptForMissingOptions(parsedArgs);
171-
consttutorial:T.Tutorial=awaitbuild(options);
172-
173-
if(tutorial){
174-
if(options.output){
175-
fs.writeFileSync(options.output,JSON.stringify(tutorial),"utf8");
176-
}else{
177-
console.log(JSON.stringify(tutorial,null,2));
178-
}
179-
}
180-
break;
181-
182-
case"create":
183-
create(process.cwd());
184-
break;
185-
}
125+
constcommand:string=args[2];
126+
127+
switch(command){
128+
case"--version":
129+
case"-v":
130+
constversion=require("../package.json").version;
131+
console.log(`v${version}`);
132+
return;
133+
case"build":
134+
// Otherwise, continue with the otheroptions
135+
// const options: BuildOptions = await promptForMissingOptions(parsedArgs);
136+
// const tutorial: T.Tutorial = await build(options);
137+
138+
// if (tutorial) {
139+
// if (options.output) {
140+
// fs.writeFileSync(options.output, JSON.stringify(tutorial), "utf8");
141+
// } else {
142+
// console.log(JSON.stringify(tutorial, null, 2));
143+
// }
144+
// }
145+
break;
146+
147+
case"create":
148+
create(process.cwd());
149+
break;
150+
case"--help":
151+
case"-h":
152+
default:
153+
console.log(
154+
"Docs can be found at github: https://github.com/coderoad/coderoad-cli/"
155+
);
186156
}
187157
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp