add flag to list and quit
maybe someday it'll do it automatically when the window is bigger than the table
This commit is contained in:
parent
0e147e283b
commit
1a9e64d473
|
@ -54,6 +54,7 @@ type model struct {
|
||||||
keys keyMap
|
keys keyMap
|
||||||
selected map[string]bool
|
selected map[string]bool
|
||||||
readonly bool
|
readonly bool
|
||||||
|
once bool
|
||||||
termheight int
|
termheight int
|
||||||
mode modes.Mode
|
mode modes.Mode
|
||||||
sorting sorting.Sorting
|
sorting sorting.Sorting
|
||||||
|
@ -61,7 +62,7 @@ type model struct {
|
||||||
files files.Files
|
files files.Files
|
||||||
}
|
}
|
||||||
|
|
||||||
func newModel(fs []files.File, width, height int, readonly, preselected bool, workdir string, mode modes.Mode) model {
|
func newModel(fs []files.File, width, height int, readonly, preselected, once bool, workdir string, mode modes.Mode) model {
|
||||||
var (
|
var (
|
||||||
fwidth int = int(math.Round(float64(width-woffset) * 0.4))
|
fwidth int = int(math.Round(float64(width-woffset) * 0.4))
|
||||||
owidth int = int(math.Round(float64(width-woffset) * 0.2))
|
owidth int = int(math.Round(float64(width-woffset) * 0.2))
|
||||||
|
@ -73,6 +74,7 @@ func newModel(fs []files.File, width, height int, readonly, preselected bool, wo
|
||||||
m = model{
|
m = model{
|
||||||
keys: defaultKeyMap(),
|
keys: defaultKeyMap(),
|
||||||
readonly: readonly,
|
readonly: readonly,
|
||||||
|
once: once,
|
||||||
termheight: height,
|
termheight: height,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
selected: map[string]bool{},
|
selected: map[string]bool{},
|
||||||
|
@ -162,12 +164,21 @@ func defaultKeyMap() keyMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Init() tea.Cmd {
|
func (m model) Init() tea.Cmd {
|
||||||
|
/* if m.onePage() {
|
||||||
|
m.table.SetStyles(makeUnselectedStyle())
|
||||||
|
m.unselectAll()
|
||||||
|
return tea.Quit
|
||||||
|
} */
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
var cmd tea.Cmd
|
var cmd tea.Cmd
|
||||||
|
|
||||||
|
if m.once {
|
||||||
|
return m.quit(true)
|
||||||
|
}
|
||||||
|
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch {
|
switch {
|
||||||
|
@ -299,6 +310,15 @@ func (m model) selectedFiles() (outfile files.Files) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* func (m model) onePage() bool {
|
||||||
|
x := m.termheight
|
||||||
|
y := len(m.table.Rows()) + hoffset
|
||||||
|
if x > y && m.readonly {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
} */
|
||||||
|
|
||||||
func newRow(file files.File, workdir string) table.Row {
|
func newRow(file files.File, workdir string) table.Row {
|
||||||
var t, b string
|
var t, b string
|
||||||
t = humanize.Time(file.Date())
|
t = humanize.Time(file.Date())
|
||||||
|
|
13
main.go
13
main.go
|
@ -34,7 +34,7 @@ var (
|
||||||
o, b, a, g, p string
|
o, b, a, g, p string
|
||||||
sm, lg string
|
sm, lg string
|
||||||
ung, unp string
|
ung, unp string
|
||||||
fo, do, sh bool
|
fo, do, sh, ni bool
|
||||||
askconfirm bool
|
askconfirm bool
|
||||||
workdir, ogdir cli.Path
|
workdir, ogdir cli.Path
|
||||||
recursive bool
|
recursive bool
|
||||||
|
@ -184,7 +184,7 @@ var (
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Usage: "List trashed files",
|
Usage: "List trashed files",
|
||||||
Flags: slices.Concat(alreadyintrashFlags, filterFlags),
|
Flags: slices.Concat(listFlags, alreadyintrashFlags, filterFlags),
|
||||||
Before: beforeCommands,
|
Before: beforeCommands,
|
||||||
Action: func(ctx *cli.Context) error {
|
Action: func(ctx *cli.Context) error {
|
||||||
log.Debugf("searching in directory %s for files", trashDir)
|
log.Debugf("searching in directory %s for files", trashDir)
|
||||||
|
@ -394,6 +394,15 @@ var (
|
||||||
Destination: &ogdir,
|
Destination: &ogdir,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listFlags = []cli.Flag{
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "non-interactive",
|
||||||
|
Usage: "list files and quit",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Destination: &ni,
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue