Compare commits
3 commits
be41eadb43
...
e57afe835d
Author | SHA1 | Date | |
---|---|---|---|
Lilian Jónsdóttir | e57afe835d | ||
Lilian Jónsdóttir | cf82990925 | ||
Lilian Jónsdóttir | a6a62f74d1 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
bin/
|
bin/
|
||||||
|
dist/
|
||||||
|
|
89
README.md
89
README.md
|
@ -15,15 +15,102 @@ Run with no command and only filename(s) as argument(s) to skip displaying files
|
||||||
Files are displayed in an interactive table, allowing them to be sorted, filtered, and selectively operated on.
|
Files are displayed in an interactive table, allowing them to be sorted, filtered, and selectively operated on.
|
||||||
|
|
||||||
### trash / tr
|
### trash / tr
|
||||||
|
|
||||||
Find files on the filesystem based on the filter flags and any filename args.
|
Find files on the filesystem based on the filter flags and any filename args.
|
||||||
|
|
||||||
|
#### flags
|
||||||
|
|
||||||
|
*--recursive*, *-r*
|
||||||
|
operate on files recursively
|
||||||
|
|
||||||
|
*--work-dir* dir, *-w* dir
|
||||||
|
operate on files in this directory
|
||||||
|
|
||||||
|
*--hidden*, *-h*
|
||||||
|
operate on hidden files
|
||||||
|
|
||||||
### list / ls
|
### list / ls
|
||||||
|
|
||||||
Find files in the trash based on the filter flags and any filename args.
|
Find files in the trash based on the filter flags and any filename args.
|
||||||
|
|
||||||
|
#### flags
|
||||||
|
|
||||||
|
*--non-interactive*, *-n*
|
||||||
|
list files and quit
|
||||||
|
|
||||||
|
*--original-path* dir, *-O* dir
|
||||||
|
list files trashed from this directory
|
||||||
|
|
||||||
### restore / re
|
### restore / re
|
||||||
|
|
||||||
Find files in the trash based on the filter flags and any filename args.
|
Find files in the trash based on the filter flags and any filename args.
|
||||||
|
|
||||||
|
#### flags
|
||||||
|
|
||||||
|
*--all*, *-a*
|
||||||
|
operate on all files in trash
|
||||||
|
|
||||||
|
*--original-path* dir, *-O* dir
|
||||||
|
restore files trashed from this directory
|
||||||
|
|
||||||
### clean / cl
|
### clean / cl
|
||||||
|
|
||||||
Find files in the trash based on the filter flags and any filename args.
|
Find files in the trash based on the filter flags and any filename args.
|
||||||
|
|
||||||
See gt(1) or `gt --help` for more in depth information on all command line flags.
|
#### flags
|
||||||
|
|
||||||
|
*--all*, *-a*
|
||||||
|
operate on all files in trash
|
||||||
|
|
||||||
|
*--original-path* dir, *-O* dir
|
||||||
|
remove files trashed from this directory
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
### Global flags
|
||||||
|
|
||||||
|
*--confirm*, *-c*
|
||||||
|
ask for confirmation before executing any action
|
||||||
|
|
||||||
|
*--log* level, *-l* level
|
||||||
|
set log level
|
||||||
|
|
||||||
|
### Filter flags (usable with all commands)
|
||||||
|
|
||||||
|
*--match* pattern, *-m* pattern
|
||||||
|
operate on files matching regex pattern
|
||||||
|
|
||||||
|
*--glob* pattern, *-m* pattern
|
||||||
|
operate on files matching glob
|
||||||
|
|
||||||
|
*--not-match* pattern, *-M* pattern
|
||||||
|
operate on files not matching regex pattern
|
||||||
|
|
||||||
|
*--not-glob* pattern, *-G* pattern
|
||||||
|
operate on files not matching glob
|
||||||
|
|
||||||
|
*--on* date, *-O* date
|
||||||
|
operate on files modified on date
|
||||||
|
|
||||||
|
*--before* date, *-B* date
|
||||||
|
operate on files modified before date
|
||||||
|
|
||||||
|
*--after* date, *-A* date
|
||||||
|
operate on files modified after date
|
||||||
|
|
||||||
|
*--files-only*, *-F*
|
||||||
|
operate on files only
|
||||||
|
|
||||||
|
*--dirs-only*, *-D*
|
||||||
|
operate on directories only
|
||||||
|
|
||||||
|
*--min-size* size, *-N* size
|
||||||
|
operate on files larger than size
|
||||||
|
|
||||||
|
*--max-size* size, *-X* size
|
||||||
|
operate on files smaller than size
|
||||||
|
|
||||||
|
*--mode* mode, *-x* mode
|
||||||
|
operate on files matching mode mode
|
||||||
|
|
||||||
|
See also gt(1) or `gt --help`.
|
||||||
|
|
2
gt.1.scd
2
gt.1.scd
|
@ -51,7 +51,7 @@ _flags_:
|
||||||
operate on files recursively
|
operate on files recursively
|
||||||
|
|
||||||
*--work-dir* dir, *-w* dir
|
*--work-dir* dir, *-w* dir
|
||||||
operate on files in this `DIRECTORY`
|
operate on files in this directory
|
||||||
|
|
||||||
*--hidden*, *-h*
|
*--hidden*, *-h*
|
||||||
operate on hidden files
|
operate on hidden files
|
||||||
|
|
|
@ -326,19 +326,14 @@ func (m model) showHelp() string {
|
||||||
|
|
||||||
if !m.readonly {
|
if !m.readonly {
|
||||||
if m.mode != modes.Interactive {
|
if m.mode != modes.Interactive {
|
||||||
keys = append([]string{
|
keys = append([]string{styleKey(m.keys.doit)}, keys...)
|
||||||
styleKey(m.keys.doit),
|
|
||||||
}, keys...)
|
|
||||||
}
|
}
|
||||||
keys = append([]string{
|
keys = append([]string{styleKey(m.keys.mark)}, keys...)
|
||||||
styleKey(m.keys.mark),
|
|
||||||
}, keys...)
|
|
||||||
}
|
}
|
||||||
return strings.Join(keys, darkesttext.Render(" • "))
|
return strings.Join(keys, darkesttext.Render(" • "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) header() string {
|
func (m model) header() string {
|
||||||
// TODO: clean this ugly thing up
|
|
||||||
var (
|
var (
|
||||||
right, left string
|
right, left string
|
||||||
spacerWidth int
|
spacerWidth int
|
||||||
|
@ -357,33 +352,30 @@ func (m model) header() string {
|
||||||
}
|
}
|
||||||
dot = darkesttext.Render("•")
|
dot = darkesttext.Render("•")
|
||||||
wideDot = darkesttext.Render(" • ")
|
wideDot = darkesttext.Render(" • ")
|
||||||
|
keysFmt = strings.Join(keys, wideDot)
|
||||||
|
selectFmt = strings.Join(selectKeys, wideDot)
|
||||||
|
filterFmt = strings.Join(filterKeys, wideDot)
|
||||||
)
|
)
|
||||||
|
|
||||||
right = " " // to offset from the table border
|
switch {
|
||||||
switch m.mode {
|
case m.filtering:
|
||||||
case modes.Interactive:
|
right = fmt.Sprintf(" Filtering %s %s", dot, filterFmt)
|
||||||
right += strings.Join(keys, wideDot)
|
case m.mode == modes.Interactive:
|
||||||
default:
|
right = fmt.Sprintf(" %s %s %s", keysFmt, dot, selectFmt)
|
||||||
right += m.mode.String()
|
|
||||||
if m.workdir != "" {
|
|
||||||
right += fmt.Sprintf(" in %s", dirs.UnExpand(m.workdir, ""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
right += fmt.Sprintf(" %s %s", dot, strings.Join(selectKeys, wideDot))
|
|
||||||
|
|
||||||
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
||||||
|
case m.mode == modes.Listing:
|
||||||
if m.mode == modes.Listing {
|
var filtered string
|
||||||
title := "Showing"
|
|
||||||
if m.filter != "" || m.filtering {
|
if m.filter != "" || m.filtering {
|
||||||
title += " (filtered)"
|
filtered = " (filtered)"
|
||||||
}
|
}
|
||||||
right = fmt.Sprintf(" %s %d files in trash", title, len(m.fltrfiles))
|
right = fmt.Sprintf(" Showing%s %d files in trash", filtered, len(m.fltrfiles))
|
||||||
left = ""
|
default:
|
||||||
|
var wd string
|
||||||
|
if m.workdir != "" {
|
||||||
|
wd = " in " + dirs.UnExpand(m.workdir, "")
|
||||||
}
|
}
|
||||||
|
right = fmt.Sprintf(" %s%s %s %s", m.mode.String(), wd, dot, selectFmt)
|
||||||
if m.filtering {
|
left = fmt.Sprintf("%d/%d %s %s", len(m.selected), len(m.fltrfiles), dot, humanize.Bytes(uint64(m.selectsize)))
|
||||||
right = fmt.Sprintf(" Filtering %s %s", dot, strings.Join(filterKeys, wideDot))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// offset of 2 again because of table border
|
// offset of 2 again because of table border
|
||||||
|
|
16
justfile
16
justfile
|
@ -1,7 +1,10 @@
|
||||||
binary := "gt"
|
binary := "gt"
|
||||||
|
version := "0.0.1"
|
||||||
build_dir := "bin"
|
build_dir := "bin"
|
||||||
|
dist_dir := "dist"
|
||||||
cmd := "."
|
cmd := "."
|
||||||
output := "." / build_dir / binary
|
output := "." / build_dir / binary
|
||||||
|
dist := "." / dist_dir / binary
|
||||||
|
|
||||||
# do the thing
|
# do the thing
|
||||||
default: test check install
|
default: test check install
|
||||||
|
@ -10,9 +13,12 @@ default: test check install
|
||||||
build:
|
build:
|
||||||
go build -o {{output}} {{cmd}}
|
go build -o {{output}} {{cmd}}
|
||||||
|
|
||||||
# build windows binary
|
package:
|
||||||
build-windows:
|
go build -o {{binary}}
|
||||||
GOOS=windows GOARCH=amd64 go build -o {{output}}.exe {{cmd}}
|
distrobox enter alpine -- go build -o {{binary}}-musl {{cmd}}
|
||||||
|
tar cafv {{dist_dir}}/{{binary}}-{{version}}-x86_64.tar.gz {{binary}} README.md LICENSE
|
||||||
|
tar cafv {{dist_dir}}/{{binary}}-{{version}}-x86_64-musl.tar.gz {{binary}}-musl README.md LICENSE
|
||||||
|
rm {{binary}} {{binary}}-musl
|
||||||
|
|
||||||
# run from source
|
# run from source
|
||||||
run:
|
run:
|
||||||
|
@ -37,7 +43,9 @@ install-man:
|
||||||
|
|
||||||
# clean up after yourself
|
# clean up after yourself
|
||||||
clean:
|
clean:
|
||||||
rm {{output}}
|
-rm {{output}}
|
||||||
|
-rm {{output}}-musl
|
||||||
|
-rm {{dist_dir}}/*
|
||||||
|
|
||||||
# run go tests
|
# run go tests
|
||||||
test:
|
test:
|
||||||
|
|
Loading…
Reference in a new issue