Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Create helper function to parse global options
Browse files Browse the repository at this point in the history
  • Loading branch information
grassias committed Mar 21, 2019
1 parent dd38867 commit 6d0996d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ const mfs = require('ipfs-mfs/cli')
const debug = require('debug')('ipfs:cli')
const pkg = require('../../package.json')

async function main (args) {
const oneWeek = 1000 * 60 * 60 * 24 * 7
updateNotifier({ pkg, updateCheckInterval: oneWeek }).notify()

const cli = yargs(args)
function globalOptions (args) {
return yargs(args)
.option('silent', {
desc: 'Write no output',
type: 'boolean',
Expand All @@ -36,16 +33,21 @@ async function main (args) {
if (err) {
throw err // preserve stack
}

if (args.length > 0) {
print(msg)
}

yargs.showHelp()
})
}

async function main (args) {
const oneWeek = 1000 * 60 * 60 * 24 * 7
updateNotifier({ pkg, updateCheckInterval: oneWeek }).notify()

const cli = globalOptions(args)

// Function to get hold of a singleton ipfs instance
const getIpfs = utils.singleton(cb => utils.getIPFS(yargs(args).argv, cb))
const getIpfs = utils.singleton(cb => utils.getIPFS(globalOptions(args).argv, cb))

// add MFS (Files API) commands
mfs(cli)
Expand Down

0 comments on commit 6d0996d

Please sign in to comment.