From c8f60623f3fd3f59d2469908d206e20dc296db72 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Tue, 13 Apr 2021 23:29:26 +0300 Subject: [PATCH] cleanup --- app.go | 8 ++++---- doc.go | 5 ++--- etc/lf.bash | 1 + etc/lf.csh | 2 +- etc/lf.fish | 1 + etc/lf.ps1 | 2 ++ etc/lf.zsh | 2 ++ etc/lfcd.ps1 | 10 +++++----- gen/man.sh | 2 ++ lf.1 | 2 ++ main.go | 16 ++++++++-------- 11 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app.go b/app.go index 3d72a284..be4a213c 100644 --- a/app.go +++ b/app.go @@ -174,11 +174,11 @@ func (app *app) loop() { }() } - if gCustomConfig != "" { - if _, err := os.Stat(gCustomConfig); !os.IsNotExist(err) { - app.readFile(gCustomConfig) + if gConfigPath != "" { + if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) { + app.readFile(gConfigPath) } else { - log.Printf("Config file does not exist: %s", err) + log.Printf("config file does not exist: %s", err) } } else { for _, path := range gConfigPaths { diff --git a/doc.go b/doc.go index 809fb509..806600ec 100644 --- a/doc.go +++ b/doc.go @@ -6,9 +6,8 @@ lf is a terminal file manager. Source code can be found in the repository at https://github.com/gokcehan/lf. -This documentation can either be read from terminal using 'lf -doc' or online -at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command -(default '') inside lf to view the documentation in a pager. +This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf. +You can also use 'doc' command (default '') inside lf to view the documentation in a pager. You can run 'lf -help' to see descriptions of command line options. diff --git a/etc/lf.bash b/etc/lf.bash index 7daeb864..99e48993 100644 --- a/etc/lf.bash +++ b/etc/lf.bash @@ -9,6 +9,7 @@ _lf () { local -a opts=( -command + -config -cpuprofile -doc -last-dir-path diff --git a/etc/lf.csh b/etc/lf.csh index e9537dca..f2b20bd6 100644 --- a/etc/lf.csh +++ b/etc/lf.csh @@ -9,7 +9,7 @@ # endif # -set LF_ARGS = "-command -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -version -help " +set LF_ARGS = "-command -config -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -version -help " complete lf "C/-*/(${LF_ARGS})/" complete lfcd "C/-*/(${LF_ARGS})/" diff --git a/etc/lf.fish b/etc/lf.fish index 9749cf9d..ba1073a0 100644 --- a/etc/lf.fish +++ b/etc/lf.fish @@ -7,6 +7,7 @@ # complete -c lf -o command -r -d 'command to execute on client initialization' +complete -c lf -o config -r -d 'path to the config file (instead of the usual paths)' complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile' complete -c lf -o doc -d 'show documentation' complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)' diff --git a/etc/lf.ps1 b/etc/lf.ps1 index d3b89faa..47b7ddd6 100644 --- a/etc/lf.ps1 +++ b/etc/lf.ps1 @@ -10,6 +10,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock { param($wordToComplete) $completions = @( [CompletionResult]::new('-command ', '-command', [CompletionResultType]::ParameterName, 'command to execute on client initialization') + [CompletionResult]::new('-config ', '-config', [CompletionResultType]::ParameterName, 'path to the config file (instead of the usual paths)') [CompletionResult]::new('-cpuprofile ', '-cpuprofile', [CompletionResultType]::ParameterName, 'path to the file to write the CPU profile') [CompletionResult]::new('-doc', '-doc', [CompletionResultType]::ParameterName, 'show documentation') [CompletionResult]::new('-last-dir-path ', '-last-dir-path', [CompletionResultType]::ParameterName, 'path to the file to write the last dir on exit (to use for cd)') @@ -18,6 +19,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock { [CompletionResult]::new('-selection-path ', '-selection-path', [CompletionResultType]::ParameterName, 'path to the file to write selected files on open (to use as open file dialog)') [CompletionResult]::new('-server', '-server', [CompletionResultType]::ParameterName, 'start server (automatic)') [CompletionResult]::new('-version', '-version', [CompletionResultType]::ParameterName, 'show version') + [CompletionResult]::new('-help', '-help', [CompletionResultType]::ParameterName, 'show help') ) if ($wordToComplete.StartsWith('-')) { diff --git a/etc/lf.zsh b/etc/lf.zsh index 3d01cb00..e73e1b5a 100644 --- a/etc/lf.zsh +++ b/etc/lf.zsh @@ -14,6 +14,7 @@ local arguments arguments=( '-command[command to execute on client initialization]' + '-config[path to the config file (instead of the usual paths)]' '-cpuprofile[path to the file to write the CPU profile]' '-doc[show documentation]' '-last-dir-path[path to the file to write the last dir on exit (to use for cd)]' @@ -22,6 +23,7 @@ arguments=( '-selection-path[path to the file to write selected files on open (to use as open file dialog)]' '-server[start server (automatic)]' '-version[show version]' + '-help[show help]' '*:filename:_files' ) diff --git a/etc/lfcd.ps1 b/etc/lfcd.ps1 index 210dd4af..64669710 100644 --- a/etc/lfcd.ps1 +++ b/etc/lfcd.ps1 @@ -4,11 +4,11 @@ # # You may also like to assign a key to this command: # -# Set-PSReadLineKeyHandler -Chord Ctrl+o -ScriptBlock { -# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() -# [Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd.ps1') -# [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() -# } +# Set-PSReadLineKeyHandler -Chord Ctrl+o -ScriptBlock { +# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() +# [Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd.ps1') +# [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() +# } # # You may put this in one of the profiles found in $PROFILE. # diff --git a/gen/man.sh b/gen/man.sh index af545cf4..7e33f620 100755 --- a/gen/man.sh +++ b/gen/man.sh @@ -24,6 +24,7 @@ lf \- terminal file manager .SH SYNOPSIS .SY lf .OP \-command command +.OP \-config path .OP \-cpuprofile path .OP \-doc .OP \-last-dir-path path @@ -32,6 +33,7 @@ lf \- terminal file manager .OP \-selection-path path .OP \-server .OP \-version +.OP \-help .RI [ directory ] .YS .SH DESCRIPTION diff --git a/lf.1 b/lf.1 index b9f83b44..d2153632 100644 --- a/lf.1 +++ b/lf.1 @@ -5,6 +5,7 @@ lf \- terminal file manager .SH SYNOPSIS .SY lf .OP \-command command +.OP \-config path .OP \-cpuprofile path .OP \-doc .OP \-last-dir-path path @@ -13,6 +14,7 @@ lf \- terminal file manager .OP \-selection-path path .OP \-server .OP \-version +.OP \-help .RI [ directory ] .YS .SH DESCRIPTION diff --git a/main.go b/main.go index 5820c55f..48dcd2da 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ var ( gLogPath string gServerLogPath string gSelect string - gCustomConfig string + gConfigPath string gCommands arrayFlag gVersion string ) @@ -188,16 +188,16 @@ func main() { false, "show version") - remoteCmd := flag.String( - "remote", - "", - "send remote command to server") - serverMode := flag.Bool( "server", false, "start server (automatic)") + remoteCmd := flag.String( + "remote", + "", + "send remote command to server") + cpuprofile := flag.String( "cpuprofile", "", @@ -218,10 +218,10 @@ func main() { "", "path to the file to write selected files on open (to use as open file dialog)") - flag.StringVar(&gCustomConfig, + flag.StringVar(&gConfigPath, "config", "", - "path to a custom config file to be used, instead of normal lfrc file") + "path to the config file (instead of the usual paths)") flag.Var(&gCommands, "command",