Skip to content

Commit 3bb92a5

Browse files
committed
change: move config files from XDG to current directory
1 parent fb36857 commit 3bb92a5

File tree

10 files changed

+23
-356
lines changed

10 files changed

+23
-356
lines changed

command/attach.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import (
1414
)
1515

1616
// AttachCommand represents a attach tmux session command.
17-
type AttachCommand struct {
18-
profile string
19-
}
17+
type AttachCommand struct {}
2018

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

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

3634
// SetFlags adds the flags for AttachCommand to the specified set.
37-
func (cmd *AttachCommand) SetFlags(f *flag.FlagSet) {
38-
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
39-
}
35+
func (cmd *AttachCommand) SetFlags(f *flag.FlagSet) {}
4036

4137
// Execute executes attach tmux session and returns an ExitStatus.
4238
func (cmd *AttachCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
43-
path, err := config.ConfigurationPath(cmd.profile)
39+
path, err := config.ConfigurationPath()
4440
if err != nil {
4541
logger.Err(err.Error())
4642
return subcommands.ExitFailure

command/delete.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

command/edit.go

Lines changed: 0 additions & 73 deletions
This file was deleted.

command/init.go

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ import (
77
"io/ioutil"
88
"os"
99
"text/template"
10+
"path/filepath"
1011

1112
"github.com/google/subcommands"
1213

1314
"tmuxist/config"
14-
path_helper "tmuxist/helper/path"
1515
"tmuxist/logger"
1616
)
1717

1818
// InitCommand represents a create configuration command.
19-
type InitCommand struct {
20-
profile string
21-
}
19+
type InitCommand struct{}
2220

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

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

3836
// SetFlags adds the flags for InitCommand to the specified set.
39-
func (cmd *InitCommand) SetFlags(f *flag.FlagSet) {
40-
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
41-
}
37+
func (cmd *InitCommand) SetFlags(f *flag.FlagSet) {}
4238

4339
// Execute executes create configuration and returns an ExitStatus.
4440
func (cmd *InitCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
45-
path, err := config.ConfigurationDirectoryPath()
46-
if err != nil {
47-
logger.Err(err.Error())
48-
return subcommands.ExitFailure
49-
}
50-
51-
cfgDirPath, err := path_helper.Fullpath(path)
52-
if err != nil {
53-
logger.Err(err.Error())
54-
return subcommands.ExitFailure
55-
}
56-
if err := os.MkdirAll(cfgDirPath, os.ModePerm); err != nil {
57-
logger.Warn(err.Error())
58-
}
59-
60-
cfgPath, err := config.ConfigurationPath(cmd.profile)
41+
cfgPath, err := config.ConfigurationPath()
6142
if err != nil {
6243
logger.Err(err.Error())
6344
return subcommands.ExitFailure
@@ -83,10 +64,11 @@ command = "echo 'hello'"`)
8364
logger.Err(err.Error())
8465
return subcommands.ExitFailure
8566
}
67+
directory := filepath.Base(currentPath)
8668
var buf bytes.Buffer
8769
attach := true
8870
err = tmpl.Execute(&buf, &config.Config{
89-
Name: cmd.profile,
71+
Name: directory,
9072
Root: currentPath,
9173
Attach: &attach,
9274
Windows: []config.Window{},

command/kill.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import (
1414
)
1515

1616
// KillCommand represents a kill tmux session command.
17-
type KillCommand struct {
18-
profile string
19-
}
17+
type KillCommand struct {}
2018

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

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

3634
// SetFlags adds the flags for KillCommand to the specified set.
37-
func (cmd *KillCommand) SetFlags(f *flag.FlagSet) {
38-
f.StringVar(&cmd.profile, "profile", config.DefaultProfileName(), "Profile")
39-
}
35+
func (cmd *KillCommand) SetFlags(f *flag.FlagSet) {}
4036

4137
// Execute executes kill tmux session and returns an ExitStatus.
4238
func (cmd *KillCommand) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
43-
path, err := config.ConfigurationPath(cmd.profile)
39+
path, err := config.ConfigurationPath()
4440
if err != nil {
4541
logger.Err(err.Error())
4642
return subcommands.ExitFailure

command/list.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

command/print.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)