[root@localhost ~]# rm --help
Usage: rm [OPTION]... FILE...
Remove (unlink) the FILE(s).
-f, --force ignore nonexistent files, never prompt
-r, -R, --recursive remove directories and their contents recursively
-v, --verbose explain what is being done
...
By default, rm does not remove directories. Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.
To remove a file whose name starts with a `-', for example `-foo',
...
Example for linux command rm help info as above, we can see the struct of
this page is exactly summary+usage+details
As you said, you can use two flags to initialize the same variable, but how
can you tell users -v/--verbose is the same one by std.flag ?
Since linux command usage has clearly tell us -v is an abbreviation for
--verbose
So, what I did is trying to get close to the convention usage.
在 2016年8月19日星期五 UTC+8上午12:03:45,Hotei写道:
>
> I assume you're aware it's valid to have two initializers for the same
> variable.? I often use -v and -verbose to both modify flagVerbose.
>
> var flagVerbose bool
>
> func init() {
> boolVar(&flagVerbose,"v" ....
> boolVar(&flagVerbose "verbose" ....
>
> }
>
> Other than that I don't see what your package is actually enhancing over
> the current flag package. Could you please explain what advantage(s) you
> believe you are providing. You might also want to re-visit the "usage"
> function convention since that's pretty easy to use to accomplish the
> "enough information" part.
>
> On Thursday, August 18, 2016 at 6:11:35 AM UTC-4, Ally Dale wrote:
>>
>> Hi, everyone,
>> I have create a package named cmdline to extend std.flag based on Go
>> src v1.7
>> Then, we can make a command usage page more easily and with enough
>> information.
>>
>> So, I wonder if the Go authors can merge this change into std.flag,
>> to help gophers make a command line page more conveniently?
>>
>> You can find the project here: http://github.com/vipally/cmdline
>>
>> This is the main change:
>>
>> 1. Add LogicName and Required field for every flag, and modify the flag
>> define interface
>>
>> 2. Add Summary and Details for command line info
>>
>> 3. Add interface GetUsage() string
>>
>> 4. Modify the Parse() logic
>>
>>
>> //usage of cmdline as follow
>>
>> import (
>>
>> "github.com/vipally/cmdline"
>>
>> )
>>
>> func main() {
>>
>> cmdline.Summary("command copy is used to copy a file to another path.")
>>
>> cmdline.Details(`Command copy is used to copy a file to another path.
>>
>> If the destnation file is exist, default ask for if will cover it.
>>
>> If flag -y used, it will cover the destnation file without ask.
>>
>> If flag -n used, it will not cover the destnation file without ask.
>>
>> `)
>>
>> cmdline.String("s", "src", ".", true, "source file path")
>>
>> cmdline.String("d", "dst", ".", true, "destnation file path")
>>
>> cmdline.Bool("c", "cover", false, false, "if cover the destnation file")
>>
>> cmdline.Bool("y", "yes", false, false, "if auto select yes when ask for
>> cover")
>>
>> cmdline.Bool("n", "no", false, false, "if auto select no when ask for
>> cover")
>>
>> cmdline.Parse()
>>
>>
>> //[error] require but lack of flag -s=<src>
>>
>> //Usage of [copy.exe]:
>>
>> // Summary:
>>
>> // command copy is used to copy a file to another path
>>
>> //
>>
>> // Usage:
>>
>> // copy.exe [-c=<cover>] -d=<dst> [-n=<no>] -s=<src> [-y=<yes>]
>>
>> // -c=<cover>
>>
>> // if cover the destnation file
>>
>> // -d=<dst> required string (default ".")
>>
>> // destination file path
>>
>> // -n=<no> if auto select no when ask for cover
>>
>> // -s=<src> required string (default ".")
>>
>> // source file path
>>
>> // -y=<yes>
>>
>> // if auto select yes when ask for cover
>>
>> //
>>
>> // Details:
>>
>> // Command copy is used to copy a file to another path.
>>
>> // If the destnation file is exist, default ask for if will cover it.
>>
>> // If flag -y used, it will cover the destnation file without ask.
>>
>> // If flag -n used, it will not cover the destnation file without ask.
>>
>> }
>>
>>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.