-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement list profiles command (#9)
* Add comment on Makefile The make command can specify multiple targets, such as `make t1 t2 ...`. The place where I added the comment is a hack to make the target only the first one and put the rest in the ARGS variable. * Tidyup configuration path func * Implement list profiles command
- Loading branch information
1 parent
11b716a
commit f6bcac9
Showing
9 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"tmuxist/config" | ||
"tmuxist/logger" | ||
|
||
"github.com/google/subcommands" | ||
) | ||
|
||
// LIstCommand represents a version command. | ||
type LIstCommand struct{} | ||
|
||
// Name returns the name of LIstCommand. | ||
func (*LIstCommand) Name() string { | ||
return "list" | ||
} | ||
|
||
// Synopsis returns a short string describing LIstCommand. | ||
func (*LIstCommand) Synopsis() string { | ||
return "List tmuxist profiles" | ||
} | ||
|
||
// Usage returns a long string explaining LIstCommand and givinig usage. | ||
func (*LIstCommand) Usage() string { | ||
return "list: show tmuxist profiles\n" | ||
} | ||
|
||
// SetFlags adds the flags for LIstCommand to the specified set. | ||
func (*LIstCommand) SetFlags(f *flag.FlagSet) { | ||
} | ||
|
||
// Execute executes print version and returns an ExitStatus. | ||
func (*LIstCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { | ||
path, err := config.ConfigurationDirectoryPath() | ||
if err != nil { | ||
logger.Err(err.Error()) | ||
logger.Err("Please execute: `tmuxist init`") | ||
return subcommands.ExitFailure | ||
} | ||
|
||
err = filepath.Walk(path, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
if info.IsDir() { | ||
return nil | ||
} | ||
|
||
_, err = filepath.Match("*.toml", path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
c, err := config.LoadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(c.Name) | ||
return nil | ||
}) | ||
if err != nil { | ||
logger.Err(err.Error()) | ||
return subcommands.ExitFailure | ||
} | ||
return subcommands.ExitSuccess | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters