Skip to content

Commit

Permalink
change: move config files from XDG to current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
corrupt952 committed Sep 2, 2024
1 parent fb36857 commit 3bb92a5
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 356 deletions.
12 changes: 4 additions & 8 deletions command/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
)

// AttachCommand represents a attach tmux session command.
type AttachCommand struct {
profile string
}
type AttachCommand struct {}

// Name returns the name of AttachCommand.
func (*AttachCommand) Name() string {
Expand All @@ -30,17 +28,15 @@ func (*AttachCommand) Synopsis() string {

// Usage returns a long string explaining AttachCommand and giving usage.
func (*AttachCommand) Usage() string {
return "kill: tmuxist kill [-profile profile]\n"
return "kill: tmuxist kill\n"
}

// SetFlags adds the flags for AttachCommand to the specified set.
func (cmd *AttachCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
}
func (cmd *AttachCommand) SetFlags(f *flag.FlagSet) {}

// Execute executes attach tmux session and returns an ExitStatus.
func (cmd *AttachCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
path, err := config.ConfigurationPath(cmd.profile)
path, err := config.ConfigurationPath()
if err != nil {
logger.Err(err.Error())
return subcommands.ExitFailure
Expand Down
58 changes: 0 additions & 58 deletions command/delete.go

This file was deleted.

73 changes: 0 additions & 73 deletions command/edit.go

This file was deleted.

32 changes: 7 additions & 25 deletions command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ import (
"io/ioutil"
"os"
"text/template"
"path/filepath"

"github.com/google/subcommands"

"tmuxist/config"
path_helper "tmuxist/helper/path"
"tmuxist/logger"
)

// InitCommand represents a create configuration command.
type InitCommand struct {
profile string
}
type InitCommand struct{}

// Name returns the name of InitCommand.
func (*InitCommand) Name() string {
Expand All @@ -32,32 +30,15 @@ func (*InitCommand) Synopsis() string {

// Usage returns a long string explaining InitCommand and giving usage.
func (*InitCommand) Usage() string {
return "init: tmuxist init [-profile profile]\n"
return "init: tmuxist init\n"
}

// SetFlags adds the flags for InitCommand to the specified set.
func (cmd *InitCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
}
func (cmd *InitCommand) SetFlags(f *flag.FlagSet) {}

// Execute executes create configuration and returns an ExitStatus.
func (cmd *InitCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
path, err := config.ConfigurationDirectoryPath()
if err != nil {
logger.Err(err.Error())
return subcommands.ExitFailure
}

cfgDirPath, err := path_helper.Fullpath(path)
if err != nil {
logger.Err(err.Error())
return subcommands.ExitFailure
}
if err := os.MkdirAll(cfgDirPath, os.ModePerm); err != nil {
logger.Warn(err.Error())
}

cfgPath, err := config.ConfigurationPath(cmd.profile)
cfgPath, err := config.ConfigurationPath()
if err != nil {
logger.Err(err.Error())
return subcommands.ExitFailure
Expand All @@ -83,10 +64,11 @@ command = "echo 'hello'"`)
logger.Err(err.Error())
return subcommands.ExitFailure
}
directory := filepath.Base(currentPath)
var buf bytes.Buffer
attach := true
err = tmpl.Execute(&buf, &config.Config{
Name: cmd.profile,
Name: directory,
Root: currentPath,
Attach: &attach,
Windows: []config.Window{},
Expand Down
12 changes: 4 additions & 8 deletions command/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
)

// KillCommand represents a kill tmux session command.
type KillCommand struct {
profile string
}
type KillCommand struct {}

// Name returns the name of KillCommand.
func (*KillCommand) Name() string {
Expand All @@ -30,17 +28,15 @@ func (*KillCommand) Synopsis() string {

// Usage returns a long string explaining KillCommand and giving usage.
func (*KillCommand) Usage() string {
return "kill: tmuxist kill [-profile profile]\n"
return "kill: tmuxist kill\n"
}

// SetFlags adds the flags for KillCommand to the specified set.
func (cmd *KillCommand) SetFlags(f *flag.FlagSet) {
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
}
func (cmd *KillCommand) SetFlags(f *flag.FlagSet) {}

// Execute executes kill tmux session and returns an ExitStatus.
func (cmd *KillCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
path, err := config.ConfigurationPath(cmd.profile)
path, err := config.ConfigurationPath()
if err != nil {
logger.Err(err.Error())
return subcommands.ExitFailure
Expand Down
71 changes: 0 additions & 71 deletions command/list.go

This file was deleted.

52 changes: 0 additions & 52 deletions command/print.go

This file was deleted.

Loading

0 comments on commit 3bb92a5

Please sign in to comment.