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
|
||||
selected map[string]bool
|
||||
readonly bool
|
||||
once bool
|
||||
termheight int
|
||||
mode modes.Mode
|
||||
sorting sorting.Sorting
|
||||
|
@ -61,7 +62,7 @@ type model struct {
|
|||
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 (
|
||||
fwidth int = int(math.Round(float64(width-woffset) * 0.4))
|
||||
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{
|
||||
keys: defaultKeyMap(),
|
||||
readonly: readonly,
|
||||
once: once,
|
||||
termheight: height,
|
||||
mode: mode,
|
||||
selected: map[string]bool{},
|
||||
|
@ -162,12 +164,21 @@ func defaultKeyMap() keyMap {
|
|||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
/* if m.onePage() {
|
||||
m.table.SetStyles(makeUnselectedStyle())
|
||||
m.unselectAll()
|
||||
return tea.Quit
|
||||
} */
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
var cmd tea.Cmd
|
||||
|
||||
if m.once {
|
||||
return m.quit(true)
|
||||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
switch {
|
||||
|
@ -299,6 +310,15 @@ func (m model) selectedFiles() (outfile files.Files) {
|
|||
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 {
|
||||
var t, b string
|
||||
t = humanize.Time(file.Date())
|
||||
|
|
13
main.go
13
main.go
|
@ -34,7 +34,7 @@ var (
|
|||
o, b, a, g, p string
|
||||
sm, lg string
|
||||
ung, unp string
|
||||
fo, do, sh bool
|
||||
fo, do, sh, ni bool
|
||||
askconfirm bool
|
||||
workdir, ogdir cli.Path
|
||||
recursive bool
|
||||
|
@ -184,7 +184,7 @@ var (
|
|||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List trashed files",
|
||||
Flags: slices.Concat(alreadyintrashFlags, filterFlags),
|
||||
Flags: slices.Concat(listFlags, alreadyintrashFlags, filterFlags),
|
||||
Before: beforeCommands,
|
||||
Action: func(ctx *cli.Context) error {
|
||||
log.Debugf("searching in directory %s for files", trashDir)
|
||||
|
@ -394,6 +394,15 @@ var (
|
|||
Destination: &ogdir,
|
||||
},
|
||||
}
|
||||
|
||||
listFlags = []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "non-interactive",
|
||||
Usage: "list files and quit",
|
||||
Aliases: []string{"n"},
|
||||
Destination: &ni,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in a new issue