change long descriptions

This commit is contained in:
fiplox 2022-09-10 21:34:14 +02:00
parent 3bbb21dfc5
commit b5db233263
5 changed files with 20 additions and 32 deletions

View File

@ -25,14 +25,14 @@ import (
// edCmd represents the ed command
var edCmd = &cobra.Command{
Use: "ed",
Use: "ed [id]",
Short: "Edit a todo",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Long: `Edit a todo giving an ID as arg1, then all args are
taken as a string.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
You can edit a due date with '-d DATE'.
You can mark a todo as completed with '-c'.
`,
Args: func(cmd *cobra.Command, args []string) error {
if cmd.Flags().NFlag() >= 1 {
if err := cobra.MinimumNArgs(1)(cmd, args); err != nil {

View File

@ -30,12 +30,12 @@ import (
var lsCmd = &cobra.Command{
Use: "ls",
Short: "List todos",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Long: `List todos. By default, lists uncompleted todos.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
If given '-c' flag, lists completed todos.
Otherwise, you can list all todos with '-a'.
You can list showing all fields with '-v'.`,
Run: func(cmd *cobra.Command, args []string) {
var todos []Todo
all, err := cmd.Flags().GetBool("all")

View File

@ -40,12 +40,9 @@ func sliceAtoi(s []string) []int {
var newCmd = &cobra.Command{
Use: "new",
Short: "Create new todo",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Long: `Create new todo with optional due date using '-d DATE'.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
You can also mark todo as completed when creating it with '-c'.`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
dateString, err := cmd.Flags().GetString("due")

View File

@ -24,14 +24,9 @@ import (
// rmCmd represents the rm command
var rmCmd = &cobra.Command{
Use: "rm",
Use: "rm [id]",
Short: "Remove a todo",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Long: `Remove a todo given its id.`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
id, err := strconv.ParseUint(args[0], 10, 0)
@ -42,5 +37,4 @@ to quickly create a Cobra application.`,
func init() {
rootCmd.AddCommand(rmCmd)
}

View File

@ -26,14 +26,11 @@ import (
var rootCmd = &cobra.Command{
Use: "todo",
Short: "Minimal todo app",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Long: `Minimal todo app which lets you create,
remove, edit and list your todos.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
You can optionally add due date and mark todo as completed.
Running without flags lists all uncompleted todos.`,
Run: lsCmd.Run,
}