1- import arg from "arg" ;
21import * as inquirer from "inquirer" ;
32import simpleGit from "simple-git/promise" ;
43import * as fs from "fs" ;
54import * as T from "../typings/tutorial" ;
65import build , { BuildOptions } from "./build" ;
76import create from "./create" ;
87
8+ // import not working
9+ const arg = require ( "arg" ) ;
10+
911type Q = inquirer . Question < any > & { choices ?: string [ ] } ;
1012
1113type ParsedArgs = {
@@ -49,18 +51,21 @@ function parseArgumentsIntoOptions(rawArgs: string[]): ParsedArgs {
4951 argv : rawArgs . slice ( 2 ) ,
5052 }
5153 ) ;
54+ console . log ( args ) ;
5255 return {
5356 command : args [ "_" ] [ 0 ] ,
5457 git : args [ "--git" ] ,
5558 dir : args [ "--dir" ] ,
5659 codeBranch : args [ "--code" ] ,
5760 setupBranch : args [ "--setup" ] ,
58- output : args [ "--output" ] ,
61+ output : args [ "--output" ] || "./config.json" ,
5962 help : args [ "--help" ] || false ,
6063 } ;
6164}
6265
63- async function promptForMissingOptions ( options : ParsedArgs ) : Promise < Options > {
66+ export async function promptForMissingOptions (
67+ options : ParsedArgs
68+ ) : Promise < Options > {
6469 const questions : Q [ ] = [ ] ;
6570
6671 // if no git remote addres is provided, assume current folder
@@ -147,7 +152,7 @@ async function promptForMissingOptions(options: ParsedArgs): Promise<Options> {
147152 } ;
148153}
149154
150- export async function cli ( args : string [ ] ) {
155+ export async function cli ( args : string [ ] ) : Promise < void > {
151156 let parsedArgs : ParsedArgs = parseArgumentsIntoOptions ( args ) ;
152157
153158 // If help called just print the help text and exit
@@ -174,11 +179,12 @@ export async function cli(args: string[]) {
174179 console . log ( JSON . stringify ( tutorial , null , 2 ) ) ;
175180 }
176181 }
177- return ;
182+ break ;
178183
179184 case "create" :
185+ console . log ( "here" ) ;
180186 create ( process . cwd ( ) ) ;
181- return ;
187+ break ;
182188 }
183189 }
184190}
0 commit comments