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

CLI getIpfs uses wrong args object #1947

Closed
hugomrdias opened this issue Mar 19, 2019 · 4 comments
Closed

CLI getIpfs uses wrong args object #1947

hugomrdias opened this issue Mar 19, 2019 · 4 comments
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now

Comments

@hugomrdias
Copy link
Member

  • Version:
  • Platform:
  • Subsystem:

Type: Bug

Severity: High

Description:

this line
https://github.com/ipfs/js-ipfs/blob/master/src/cli/bin.js#L48
passes an argv obj that wasn't created with our yargs config

This makes cmds like ipfs add --silent ./path/file to instantiate IPFS with { silent : './path/file' }

Right now master doesn't fail because silent wasn't added to the validation yet, still this behaviour should be fixed.

Steps to reproduce the error:

@grassias
Copy link
Contributor

If we changed the line https://github.com/ipfs/js-ipfs/blob/master/src/cli/bin.js#L48
into: const getIpfs = utils.singleton(cb => utils.getIPFS(cli.argv, cb))?
That'll do it?

@alanshaw
Copy link
Member

alanshaw commented Mar 21, 2019

Sadly no, argv is an accessor that causes a handler for the command to be invoked. At the point where getIpfs is called we're already in a handler so we need a new yargs which doesn't have the commands handlers. All we're missing is the ability to parse the global options (--silent and --pass).

I think we just need a helper function to create a new yargs with the global options that we can use and assign to cli as well as use in getIpfs.

@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) exp/novice Someone with a little familiarity can pick up status/ready Ready to be worked P3 Low: Not priority right now labels Mar 21, 2019
@hugomrdias
Copy link
Member Author

made some suggestions in the #1955 PR

@ghost ghost removed the status/ready Ready to be worked label Mar 26, 2019
@alanshaw
Copy link
Member

Thanks again @grassias ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now
Projects
None yet
Development

No branches or pull requests

3 participants