Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gokcehan committed Apr 13, 2021
1 parent fec767d commit c8f6062
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 21 deletions.
8 changes: 4 additions & 4 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<f-1>') 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 '<f-1>') inside lf to view the documentation in a pager.
You can run 'lf -help' to see descriptions of command line options.
Expand Down
1 change: 1 addition & 0 deletions etc/lf.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
_lf () {
local -a opts=(
-command
-config
-cpuprofile
-doc
-last-dir-path
Expand Down
2 changes: 1 addition & 1 deletion etc/lf.csh
Original file line number Diff line number Diff line change
Expand Up @@ -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})/"
1 change: 1 addition & 0 deletions etc/lf.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
2 changes: 2 additions & 0 deletions etc/lf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand All @@ -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('-')) {
Expand Down
2 changes: 2 additions & 0 deletions etc/lf.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)]'
Expand All @@ -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'
)

Expand Down
10 changes: 5 additions & 5 deletions etc/lfcd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
2 changes: 2 additions & 0 deletions gen/man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +33,7 @@ lf \- terminal file manager
.OP \-selection-path path
.OP \-server
.OP \-version
.OP \-help
.RI [ directory ]
.YS
.SH DESCRIPTION
Expand Down
2 changes: 2 additions & 0 deletions lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,6 +14,7 @@ lf \- terminal file manager
.OP \-selection-path path
.OP \-server
.OP \-version
.OP \-help
.RI [ directory ]
.YS
.SH DESCRIPTION
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
gLogPath string
gServerLogPath string
gSelect string
gCustomConfig string
gConfigPath string
gCommands arrayFlag
gVersion string
)
Expand Down Expand Up @@ -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",
"",
Expand All @@ -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",
Expand Down

0 comments on commit c8f6062

Please sign in to comment.