Skip to content

core/commands/add: Command-line <path> argument are optional - #1151

Closed
wking wants to merge 1 commit into
ipfs:masterfrom
wking:ipfs-add-stdin-docs
Closed

wking wants to merge 1 commit into
ipfs:masterfrom
wking:ipfs-add-stdin-docs

Conversation

@wking

@wking wking commented Apr 27, 2015

Copy link
Copy Markdown
Contributor

Adding a file from stdin works now, so pass that information along to
the user.

Adding a file from stdin works now, so pass that information along to
the user.
@whyrusleeping

Copy link
Copy Markdown
Member

I dont think required should be set to false. The requirement will be satisfied by piping through stdin.

Comment thread core/commands/add.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think required still needs to be true. there's a complication here with the cmds lib because stdin counts as satisfying the requirement.

this comes from viewing stdin as just another file. which is what many cli tools do, but may not be the best model.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, the text should ideally fit in one line because it will be munged and placed in various places. (we could perhaps come up with a char limit) maybe:

The path to a file to be added to IPFS. If not set, uses stdin.

? not sure if stdin is too unfriendly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, Apr 27, 2015 at 04:29:20PM -0700, Juan Batiz-Benet wrote:

  •   cmds.FileArg("path", true, true, "The path to a file to be added to IPFS").EnableRecursive().EnableStdin(),
    

i think required still needs to be true. there's a complication here
with the cmds lib because stdin counts as satisfying the
requirement.

Hmm. I think we need to make a distinction there, and maybe
automatically add the wrapping braces (β€˜[]’) if EnableStdin() is
set (and auto-add a trailing ellipsis (β€˜[ …]’) if
EnableRecursive() is set.

this comes from viewing stdin as just another file. which is what
many cli tools do, but may not be the best model.

I like being able to add a file from stdin, but maybe don't bind the
two ideas (file paths from argument names or file content from stdin)
together so tightly. Paths strings and an input stream aren't
interchangeable (e.g. we can read owner/group IDs from an input path,
but we lose that information if we pipe the file content into stdin).

So should I be PRing commands/argument.go instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to make a distinction there, and maybe automatically add the wrapping braces (β€˜[]’) if EnableStdin() is set (and auto-add a trailing ellipsis (β€˜[ …]’) if EnableRecursive() is set.

Yeah. though not sure whether it's worth the time yet? i doubt it will be a trivial change. shrug

Paths strings and an input stream aren't interchangeable (e.g. we can read owner/group IDs from an input path, but we lose that information if we pipe the file content into stdin).

Yeah, fair point.

So should I be PRing commands/argument.go instead?

maybe? it's a bit of a mess in there. if you want to learn it go for it. else-- what is the problem being solved here? what is wrong by keeping it as is for now? (the cmds lib will get a big facelift at some point, so we can make sure to address this then)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, Apr 27, 2015 at 05:14:07PM -0700, Juan Batiz-Benet wrote:

… what is the problem being solved here? what is wrong by keeping it
as is for now? (the cmds lib will get a big facelift at some point,
so we can make sure to address this then)

I didn't realize β€˜ipfs add’ could read from stdin until you told me it
could 1. It seemed easy enough to update the command so the docs
would reflect that reality, and why have fixable errors in your docs?

But I agree that this is more of a UX issue than a functional issue,
so if the cmds lib looks to hairy I'll just leave it alone ;).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh πŸ‘ on the comment, for sure. fixing the stdin / file distinction seems more trouble than useful atm. sorry for being unclear!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wking and @jbenet I think that the documentation might need to change anyway if I add the --stdin option as discussed in issue #1141.

@wking wking mentioned this pull request Apr 28, 2015
4 of 22 tasks
@wking wking removed the ready label May 4, 2015
@whyrusleeping

Copy link
Copy Markdown
Member

@wking update here? lets merge or close soon

@whyrusleeping whyrusleeping mentioned this pull request Jun 2, 2015
13 of 58 tasks
@whyrusleeping whyrusleeping mentioned this pull request Jun 9, 2015
17 of 50 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants