@@ -37,12 +37,12 @@ function printUsage(filter?: string) {
3737 }
3838 if ( ! filter || filter === 'ingest' ) {
3939 console . log ( `
40- - ingest <source > <vault > [-p password]
40+ - ingest <vault > <source > [-p password]
4141
4242 Encrypt and copy source folders/files into vault
4343
44- <source> Source directory
4544 <vault> Vault directory
45+ <source> Source directory
4646 [-p password] Encryption password` ) ;
4747 }
4848 if ( ! filter || filter === 'init' ) {
@@ -80,6 +80,12 @@ function printUsage(filter?: string) {
8080 <vault> Vault directory
8181 [-p password] Encryption password` ) ;
8282 }
83+ if ( ! filter || filter === 'version' ) {
84+ console . log ( `
85+ - version
86+
87+ Output version of staticvault` ) ;
88+ }
8389}
8490
8591function promptPassword ( prompt : string ) : string {
@@ -173,8 +179,8 @@ async function cmdDump(args: string[]): Promise<number> {
173179}
174180
175181async function cmdIngest ( args : string [ ] ) : Promise < number > {
176- let source : string | null = null ;
177182 let target : string | null = null ;
183+ let source : string | null = null ;
178184 let password : string | null = null ;
179185 for ( ; ; ) {
180186 const arg = args . shift ( ) ;
@@ -193,24 +199,24 @@ async function cmdIngest(args: string[]): Promise<number> {
193199 console . error ( `\nCannot specify password more than once` ) ;
194200 return 1 ;
195201 }
196- } else if ( source === null ) {
197- source = arg ;
198202 } else if ( target === null ) {
199203 target = arg ;
204+ } else if ( source === null ) {
205+ source = arg ;
200206 } else {
201207 printUsage ( 'ingest' ) ;
202208 console . error ( `\nUnknown argument: ${ arg } ` ) ;
203209 return 1 ;
204210 }
205211 }
206- if ( source === null ) {
212+ if ( target === null ) {
207213 printUsage ( 'ingest' ) ;
208- console . error ( `\nMissing source directory` ) ;
214+ console . error ( `\nMissing vault directory` ) ;
209215 return 1 ;
210216 }
211- if ( target === null ) {
217+ if ( source === null ) {
212218 printUsage ( 'ingest' ) ;
213- console . error ( `\nMissing vault directory` ) ;
219+ console . error ( `\nMissing source directory` ) ;
214220 return 1 ;
215221 }
216222 if ( password === null ) {
@@ -656,6 +662,17 @@ async function cmdTree(args: string[]): Promise<number> {
656662 return 0 ;
657663}
658664
665+ async function cmdVersion ( args : string [ ] ) : Promise < number > {
666+ const data = await fs . readFile ( path . join ( __dirname , '..' , 'package.json' ) , { encoding : 'utf8' } ) ;
667+ const pack = JSON . parse ( data ) ;
668+ console . log ( `StaticVault v${ pack . version }
669+ Encrypt, host, and share files on a static website
670+ by Sean Connelly (@velipso), https://sean.fun
671+ Project Home: https://github.com/velipso/staticvault
672+ SPDX-License-Identifier: 0BSD` ) ;
673+ return 0 ;
674+ }
675+
659676async function main ( args : string [ ] ) : Promise < number > {
660677 if ( args . length <= 0 ) {
661678 printUsage ( ) ;
@@ -675,6 +692,8 @@ async function main(args: string[]): Promise<number> {
675692 return cmdTest ( args ) ;
676693 case 'tree' :
677694 return cmdTree ( args ) ;
695+ case 'version' :
696+ return cmdVersion ( args ) ;
678697 default :
679698 printUsage ( ) ;
680699 console . error ( `\nUnknown command: ${ cmd } ` ) ;
0 commit comments