This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 1 file changed +14
-12
lines changed
1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,11 @@ const mfs = require('ipfs-mfs/cli')
11
11
const debug = require ( 'debug' ) ( 'ipfs:cli' )
12
12
const pkg = require ( '../../package.json' )
13
13
14
- function globalOptions ( args ) {
15
- return yargs ( args )
14
+ async function main ( args ) {
15
+ const oneWeek = 1000 * 60 * 60 * 24 * 7
16
+ updateNotifier ( { pkg, updateCheckInterval : oneWeek } ) . notify ( )
17
+
18
+ const cli = yargs ( args )
16
19
. option ( 'silent' , {
17
20
desc : 'Write no output' ,
18
21
type : 'boolean' ,
@@ -33,35 +36,34 @@ function globalOptions (args) {
33
36
if ( err ) {
34
37
throw err // preserve stack
35
38
}
39
+
36
40
if ( args . length > 0 ) {
37
41
print ( msg )
38
42
}
43
+
39
44
yargs . showHelp ( )
40
45
} )
41
- }
42
46
43
- async function main ( args ) {
44
- const oneWeek = 1000 * 60 * 60 * 24 * 7
45
- updateNotifier ( { pkg, updateCheckInterval : oneWeek } ) . notify ( )
46
-
47
- const cli = globalOptions ( args )
48
-
49
- // Function to get hold of a singleton ipfs instance
50
- const getIpfs = utils . singleton ( cb => utils . getIPFS ( globalOptions ( args ) . argv , cb ) )
47
+ let getIpfs = null
51
48
52
49
// add MFS (Files API) commands
53
50
mfs ( cli )
54
51
55
52
cli
56
53
. commandDir ( 'commands' )
54
+ . middleware ( argv => {
55
+ // Function to get hold of a singleton ipfs instance
56
+ getIpfs = argv . getIpfs = utils . singleton ( cb => utils . getIPFS ( argv , cb ) )
57
+ return argv
58
+ } )
57
59
. help ( )
58
60
. strict ( )
59
61
. completion ( )
60
62
61
63
let exitCode = 0
62
64
63
65
try {
64
- const { data } = await new YargsPromise ( cli , { getIpfs } ) . parse ( args )
66
+ const { data } = await new YargsPromise ( cli ) . parse ( args )
65
67
if ( data ) print ( data )
66
68
} catch ( err ) {
67
69
debug ( err )
You can’t perform that action at this time.
0 commit comments