@@ -85,22 +85,38 @@ Last generated ${new Date().toISOString()}
8585
8686// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts
8787if ( import . meta. main ) {
88- let adrdir = Deno . cwd ( ) ;
89- if ( ! adrdir . endsWith ( "adr" ) ) {
90- // we need to add the adr folder
91- adrdir = path . join ( adrdir , "adr" ) ;
92- }
93-
94- const files = await getAllFilesInDir ( adrdir ) ;
95- await ensureAssetsDirExists ( adrdir ) ;
96- const adrsOnly = files . filter ( ( f ) => / ^ \d { 5 } - .* $ / . test ( f . name ) ) ;
9788 const action = Deno . args [ 0 ] ;
89+ if ( action === "help" || ( action !== "create" && action !== "regen" ) ) {
90+ console . log ( `adl
91+ Manage your Architecture Reference Diagrams with ease.
9892
99- if ( action == "create" ) {
100- const name = Deno . args . slice ( 1 ) . join ( " " ) ;
101- const newFile = await makeNewADR ( adrdir , adrsOnly . length , name ) ;
102- files . push ( newFile ) ;
103- }
93+ help menu
10494
105- await rebuildReadme ( adrdir , files ) ;
95+ supported arguments
96+
97+ create - adl create my-new-adr-name
98+ create a new ADR
99+
100+ regen - adl regen
101+ regenerate the ADR README
102+ ` ) ;
103+ } else {
104+ let adrdir = Deno . cwd ( ) ;
105+ if ( ! adrdir . endsWith ( "adr" ) ) {
106+ // we need to add the adr folder
107+ adrdir = path . join ( adrdir , "adr" ) ;
108+ }
109+
110+ const files = await getAllFilesInDir ( adrdir ) ;
111+ await ensureAssetsDirExists ( adrdir ) ;
112+ const adrsOnly = files . filter ( ( f ) => / ^ \d { 5 } - .* $ / . test ( f . name ) ) ;
113+
114+ if ( action == "create" ) {
115+ const name = Deno . args . slice ( 1 ) . join ( " " ) ;
116+ const newFile = await makeNewADR ( adrdir , adrsOnly . length , name ) ;
117+ files . push ( newFile ) ;
118+ }
119+
120+ await rebuildReadme ( adrdir , files ) ;
121+ }
106122}
0 commit comments