Skip to content

Commit

Permalink
remove short only options from put command for go install to work
Browse files Browse the repository at this point in the history
  • Loading branch information
umlx5h committed Jan 8, 2024
1 parent 79c5092 commit 01581a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ sudo mv ./gtrash /usr/local/bin/gtrash
brew install umlx5h/tap/gtrash
```

### Go install

```
go install github.com/umlx5h/gtrash@latest
```

### Build from source

```bash
Expand Down Expand Up @@ -306,13 +312,13 @@ While `rm` uses the [unlink](https://man7.org/linux/man-pages/man2/unlink.2.html
```bash
$ gtrash put -h
Flags:
-d, --dir ignored unless --rm-mode set
-f, --force ignore nonexistent files and arguments
-i, --interactive prompt before every removal
-I prompt once before trashing
-r, -R, --recursive ignored unless --rm-mode set
--rm-mode enable rm-like mode (change behavior -r, -R, -d)
-v, --verbose explain what is being done
-d, --dir ignored unless --rm-mode set
-f, --force ignore nonexistent files and arguments
-i, --interactive prompt before every removal
-I, --interactive-once prompt once before trashing
-r, -R, --recursive ignored unless --rm-mode set
--rm-mode enable rm-like mode (change behavior -r, -R, -d)
-v, --verbose explain what is being done
```

The `-r` option is not necessary for deleting folders since files are restorable even if mistakenly removed.
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ require (
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/spf13/pflag => github.com/cornfeedhobo/pflag v1.1.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cornfeedhobo/pflag v1.1.0 h1:hZ356pzRepv6EbQ3M5Yx0ZyvQnTj8rgGKm6PCTFy2kc=
github.com/cornfeedhobo/pflag v1.1.0/go.mod h1:ROo/cqBpAh84jplPcXiI5HTjyLmtp04WaPKkHC18E6U=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -79,6 +77,8 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/umlx5h/go-runewidth v0.0.0-20240106112317-9bbbb3702d5f h1:T8MNFeOIelXNJyNQ5WIMz2zUXYpUq71+3Z5dbXqWCd8=
Expand Down
7 changes: 5 additions & 2 deletions internal/cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func newPutCmd() *putCmd {
}
cmd.Flags().BoolVarP(&root.opts.force, "force", "f", false, "ignore nonexistent files and arguments")
cmd.Flags().BoolVarP(&root.opts.prompt, "interactive", "i", false, "prompt before every removal")
cmd.Flags().BoolVarS(&root.opts.promptOnce, "I", "I", false, "prompt once before trashing")
// short only options are not available
cmd.Flags().BoolVarP(&root.opts.promptOnce, "interactive-once", "I", false, "prompt once before trashing")
cmd.Flags().BoolVarP(&root.opts.verbose, "verbose", "v", false, "explain what is being done")

// rm mode options if --rm-mode used
Expand All @@ -96,7 +97,9 @@ func newPutCmd() *putCmd {
remove empty directories (--rm-mode)`)
cmd.Flags().BoolVarP(&root.opts.recursive, "recursive", "r", false, `ignored unless --rm-mode set
remove directories and their contents recursively (--rm-mode)`)
cmd.Flags().BoolVarS(&root.opts.recursive, "R", "R", false, "same as -r")

// TODO: Since short only options are not available, have no choice but to assign a long name.
cmd.Flags().BoolVarP(&root.opts.recursive, "Recursive", "R", false, "same as -r")

cmd.Flags().BoolVar(&root.opts.homeFallback, "home-fallback", env.HOME_TRASH_FALLBACK_COPY, `Enable fallback to home directory trash
If the deletion of a file in an external file system fails, this option may help.`)
Expand Down

0 comments on commit 01581a1

Please sign in to comment.