Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &Z.Cmd{ Name: "archive", Summary: "archives a users list", Commands: []*Z.Cmd{ help.Cmd, }, Comp: complist.New(), Usage: "<list name>", NumArgs: 1, Call: func(_ *Z.Cmd, args ...string) error { files, err := list.List() if err != nil { return err } if _, ok := files[args[0]]; !ok { return fmt.Errorf("list %q does not exist", args[0]) } archive := false prompt := &survey.Confirm{ Message: fmt.Sprintf("Are you sure you want to archive %s?", args[0]), } survey.AskOne(prompt, &archive) if !archive { return nil } directory := filepath.Dir(files[args[0]]) base := filepath.Base(files[args[0]]) archiveDir := filepath.Join(directory, "archive") if _, err := os.Stat(archiveDir); os.IsNotExist(err) { err := os.Mkdir(archiveDir, 0755) if err != nil { return err } } newPath := filepath.Join(archiveDir, base) err = os.Rename(files[args[0]], newPath) if err != nil { return err } return nil }, }
rootCmd is the main command for the list command line tool its just holds all the other useful commands
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.