Add input file and os.Stdin support#5
Open
pantsing wants to merge 1 commit intoskip2:masterfrom
pantsing:master
Open
Add input file and os.Stdin support#5pantsing wants to merge 1 commit intoskip2:masterfrom pantsing:master
pantsing wants to merge 1 commit intoskip2:masterfrom
pantsing:master
Conversation
skip2
reviewed
Jan 14, 2017
| } | ||
|
|
||
| content := strings.Join(flag.Args(), " ") | ||
| if *inFile != "" { |
Owner
There was a problem hiding this comment.
I suggest prioritising the -i flag, then command line arguments, then reading from STDIN last, like:
content := ""
argsContent := strings.Join(flag.Args(), " ")
if *inFile != "" {
b, err := ioutil.ReadFile(*inFile)
if err != nil {
checkError(err)
}
content = string(b)
} else if argsContent != "" {
content = argsContent
} else {
b, err := ioutil.ReadAll(os.Stdin)
if err != nil {
checkError(err)
}
content = string(b)
}
skip2
reviewed
Jan 14, 2017
| } | ||
|
|
||
| content := strings.Join(flag.Args(), " ") | ||
| if *inFile != "" { |
Owner
There was a problem hiding this comment.
Hey,
I think reading content from STDIN/a file is a nice addition :)
After this pull request there are three ways to specify content:
- String from input file:
$ qrcode -i input_filename | display
- String on command line:
$ qrcode hello | display
- String on STDIN:
$ echo -n hello | qrcode | display
- No arguments: (same as string on STDIN, only you type into the terminal and then press Ctrl+D)
$ qrcode | display
If you try the "qrcode hello | display" method, it now hangs and waits for something on STDIN.
I suggest taking content from one source only (first the -i flag, then command line arguments, or lastly STDIN), so the usage is more obvious and easier to explain. This would work well.
thanks,
Tom
Author
|
Thanks Tom, you are right. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
now it can be used as $cat name card.vcf | qrcode -o name card.png