PrintCommandLineWithCursor prints the same command-line that was used for executing the program but adding or replacing the --cursor flag with the current cursor for the given iterator.
(it *vt.Iterator)
| 254 | // executing the program but adding or replacing the --cursor flag with |
| 255 | // the current cursor for the given iterator. |
| 256 | func (p *Printer) PrintCommandLineWithCursor(it *vt.Iterator) { |
| 257 | if cursor := it.Cursor(); cursor != "" { |
| 258 | args := p.cmd.Flags().Args() |
| 259 | for i, arg := range args { |
| 260 | args[i] = fmt.Sprintf("'%s'", arg) |
| 261 | } |
| 262 | flags := make([]string, 0) |
| 263 | p.cmd.Flags().Visit(func(flag *pflag.Flag) { |
| 264 | if flag.Name != "cursor" { |
| 265 | var f string |
| 266 | switch flag.Value.Type() { |
| 267 | case "stringSlice": |
| 268 | ss, _ := p.cmd.Flags().GetStringSlice(flag.Name) |
| 269 | f = fmt.Sprintf("--%s='%s'", flag.Name, strings.Join(ss, ",")) |
| 270 | default: |
| 271 | f = fmt.Sprintf("--%s=%v", flag.Name, flag.Value.String()) |
| 272 | } |
| 273 | flags = append(flags, f) |
| 274 | } |
| 275 | }) |
| 276 | flags = append(flags, fmt.Sprintf("--cursor=%s", cursor)) |
| 277 | color.New(color.Faint).Fprintf( |
| 278 | ansi.NewAnsiStderr(), "\nMORE WITH:\n%s %s %s\n", |
| 279 | p.cmd.CommandPath(), strings.Join(args, " "), strings.Join(flags, " ")) |
| 280 | } |
| 281 | } |
no outgoing calls
no test coverage detected