Skip to content

Commit

Permalink
Merge pull request #12 from BenjuhminStewart/style-change-use-cmd-to-new
Browse files Browse the repository at this point in the history
style: change `use` command to `new`
  • Loading branch information
BenjuhminStewart authored Jun 10, 2024
2 parents 254b537 + a5a35d5 commit ed13437
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
23 changes: 11 additions & 12 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ stew add <name_of_stew> [flags]
Flags:
-d, --description string Description of the stew (default "no description provided")
-g, --git If the stew uses git
-h, --help help for add
-p, --path string Path to the stew (defaults to current directory)
```
Expand Down Expand Up @@ -62,30 +61,30 @@ Global Flags:
--config string config file (default is $HOME/.config/stew/config.yaml)
```

## remove
### new
```
Remove a stew
Create a new instance of a stew from a given name
Usage:
stew remove <name_of_stew> [flags]
stew new <name_of_stew> [flags]
Flags:
-h, --help help for remove
-h, --help help for new
-p, --path string The path to the stew (defaults to current directory)
Global Flags:
--config string config file (default is $HOME/.config/stew/config.yaml)
Global Flags:
--config string config file (default is $HOME/.config/stew/config.yaml)
```

### use
## remove
```
Use a stew from a given name
Remove a stew
Usage:
stew use <name_of_stew> [flags]
stew remove <name_of_stew> [flags]
Flags:
-h, --help help for use
-p, --path string The path to the stew (defaults to current directory)
-h, --help help for remove
Global Flags:
--config string config file (default is $HOME/.config/stew/config.yaml)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go install github.com/BenjuhminStewart/stew@latest
- `stew get`: get a stew given a certain id or name
- `stew list`: list all stew templates
- `stew remove`: remove a stew template
- `stew use`: use a stew template
- `stew new`: create a new instance of a stew template

For more information on usage, checkout the [DOC.md](https://github.com/BenjuhminStewart/stew/blob/main/DOC.md) file.

Expand All @@ -37,6 +37,6 @@ Personally, there are certain templates I like to start with for markdown files,
A good way to do this is to have some folder of templates you like for example in `$HOME/.config/stew/templates` or `$HOME/Documents/templates` and add new stews directed toward those paths.

For example, say you make a templates directory at `$HOME/Documents/templates` and you made a basic markdown template for when you take notes or configure a README at `$Home/Documents/templates/markdown`. You can then use `stew add markdown -p $HOME/Documents/templates/markdown -d "basic README layout"` to save it in your stews and later when you want to use it in a directory simply run `stew use markdown` and your markdown file will be copied over for easy use!
For example, say you make a templates directory at `$HOME/Documents/templates` and you made a basic markdown template for when you take notes or configure a README at `$Home/Documents/templates/markdown`. You can then use `stew add markdown -p $HOME/Documents/templates/markdown -d "basic README layout"` to save it in your stews and later when you want to use it in a directory simply run `stew new markdown` and your markdown file will be copied over for easy use!

You may be wondering how this is any different from running a simple `cp -r dir1 dir2` and it comes down to organization and ease of use. I simply prefer being able to run `stew list` and see all my created stews and be able to set descriptions and configure it the way I want than to just use `cp -r`. I plan to add many more features to take this above and beyond but I need help coming up with those ideas. So if you have any requests please create an Issue or contribute yourself by cloning the repo and submitting a PR. I will do my best to review promptly.
4 changes: 1 addition & 3 deletions cmd/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var AddCmd = &cobra.Command{
name := args[0]
description, _ := cmd.Flags().GetString("description")
path, _ := cmd.Flags().GetString("path")
usesGit, _ := cmd.Flags().GetBool("git")

st := types.Stews{}

Expand All @@ -45,7 +44,7 @@ var AddCmd = &cobra.Command{
description = "no description provided"
}

st.Add(name, description, path, usesGit)
st.Add(name, description, path)
err := st.Save(viper.GetString("stewsPath"))
if err != nil {
fmt.Println(err)
Expand All @@ -62,7 +61,6 @@ func getCWD() string {
func addFlag() {
AddCmd.Flags().StringP("description", "d", "no description provided", "Description of the stew")
AddCmd.Flags().StringP("path", "p", getCWD(), "Path to the stew")
AddCmd.Flags().BoolP("git", "g", false, "If the stew uses git")

}

Expand Down
14 changes: 7 additions & 7 deletions cmd/use/use.go → cmd/new/new.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright © 2024 Benjamin Stewart <[email protected]
*/
package use
package new

import (
"fmt"
Expand All @@ -11,11 +11,11 @@ import (
"github.com/spf13/viper"
)

// UseCmd represents the init command
var UseCmd = &cobra.Command{
Use: "use <name_of_stew>",
Short: "Use a stew instance to create a new project",
Long: `stew use <name_of_stew> [flags]`,
// NewCmd represents the init command
var NewCmd = &cobra.Command{
Use: "new <name_of_stew>",
Short: "Create a new instance of a stew template to create a new project",
Long: `stew new <name_of_stew> [flags]`,
Run: func(cmd *cobra.Command, args []string) {
s := types.Stews{}
err := s.Load(viper.GetString("stewsPath"))
Expand Down Expand Up @@ -59,7 +59,7 @@ var UseCmd = &cobra.Command{
}

func flags() {
UseCmd.Flags().StringP("path", "p", "", "The path to the stew (defaults to current directory)")
NewCmd.Flags().StringP("path", "p", "", "The path to the stew (defaults to current directory)")
}

func init() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/BenjuhminStewart/stew/cmd/edit"
"github.com/BenjuhminStewart/stew/cmd/get"
"github.com/BenjuhminStewart/stew/cmd/list"
"github.com/BenjuhminStewart/stew/cmd/new"
"github.com/BenjuhminStewart/stew/cmd/remove"
"github.com/BenjuhminStewart/stew/cmd/use"
"github.com/BenjuhminStewart/stew/util"
)

Expand Down Expand Up @@ -50,7 +50,7 @@ func addSubCommands() {
rootCmd.AddCommand(edit.EditCmd)
rootCmd.AddCommand(list.ListCmd)
rootCmd.AddCommand(remove.RemoveCmd)
rootCmd.AddCommand(use.UseCmd)
rootCmd.AddCommand(new.NewCmd)
rootCmd.AddCommand(get.GetCmd)
}

Expand Down
2 changes: 1 addition & 1 deletion types/stew.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (st Stew) PrintRemoved() {
fmt.Printf("\n`%v%s%v` has been removed from your stews 👋\n", red, st.Name, reset)
}

func (st *Stews) Add(name string, description string, path string, usesGit bool) {
func (st *Stews) Add(name string, description string, path string) {
if st.doesStewExist(path) {
fmt.Printf("\n`%v%s%v` already exists in your stews\n", red, name, reset)
return
Expand Down

0 comments on commit ed13437

Please sign in to comment.