
There's no work to do, so no work should be done. As a side note, running the tool with no arguments whatsoever should probably not result in an error. This expands out subdirectories and lists the files contained within them. To list all files recursively from the command line, you can attach the -R flag to the traditional ls command. Create a package level variable: var ( required string fooCmd flag.NewFlagSet ('foo', flag.ExitOnError) barCmd flag.NewFlagSet ('bar', flag. List All Files & Subdirectory Contents from the Command Line. But it's easy to register them once (in one place). This means that it's perfectly ok to run the script without any options. Yes, for this to work, all flag sets should contain the common flags. To view a file’s current flags, use the ls -lo command. To unset a flag, use the same command but with no added to the front of the flag’s name. flags is a comma-separated list of file flags, described below. The code, as written above uses sensible defaults (these should be mentioned in the help text). chflags options flags files Changes the file flags of one or more files. This is what the loop afterwards iterates over. The osquery shell and daemon use optional command-line (CLI) flags to control initialization, disable/enable features, and select plugins.

You can print opts.IgnoreLatest and opts.IgnoreOld to see the changed value.

The shift, by the way, gets rid of all the parsed options from so that only pathname operands are left in the list of positional parameters. 3 Answers Sorted by: 2 You should use func GetCommandFlags (cmd cobra.Command, opts ListOptions) and call the func like cmd GetCommandFlags (cmd, &opts). I would suggest that you instead of a loop considered using find for doing recursion (possibly in all cases, even if the recursion flag isn't set).
Os xlist all the flags for a command code#
Note that the code after the shift is just example code. It's easier if you set individual flags for each option that is activated, so that you don't have yet another string to parse just to check whether an option was used.
