Created
October 2, 2022 13:12
-
-
Save afarid/d12e2ff4b723459020d36c89dd4e7d6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var removeCmd = &cobra.Command{ | |
| .... | |
| Run: func(cmd *cobra.Command, args []string) { | |
| if len(args) == 1 { | |
| todoName := args[0] | |
| for i := 0; i < len(todos.Todos); i++ { | |
| if todos.Todos[i].Name == todoName { | |
| todos.Todos = append(todos.Todos[0:i], todos.Todos[i+1:]...) | |
| break | |
| } | |
| } | |
| viper.Set("todos", todos.Todos) | |
| err := viper.WriteConfig() | |
| if err != nil { | |
| fmt.Println(err) | |
| return | |
| } | |
| } | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment