Skip to content

Commit

Permalink
feat: Use .smug.yml as a default configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaaaan committed Sep 20, 2022
1 parent 9097aae commit 01986eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .smug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
session: smug

root: .

windows:
- name: code
commands:
- go test ./...
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ xyz@localhost:~$ smug start -f ./project.yml -w window1 -w window2

## Configuration

Configuration files stored in the `~/.config/smug` directory in the `YAML` format, e.g `~/.config/smug/your_project.yml`.
Configuration files can stored in the `~/.config/smug` directory in the `YAML` format, e.g `~/.config/smug/your_project.yml`.
You may also create a file named `.smug.yml` in the current working directory, which will be used by default.

### Examples

Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Examples:
$ smug print > ~/.config/smug/blog.yml
`, version, FileUsage, WindowsUsage, AttachUsage, InsideCurrentSessionUsage, DebugUsage, DetachUsage)

const defaultConfigFile = ".smug.yml"

func newLogger(path string) *log.Logger {
logFile, err := os.Create(filepath.Join(path, "smug.log"))
if err != nil {
Expand Down Expand Up @@ -87,8 +89,15 @@ func main() {
var configPath string
if options.Config != "" {
configPath = options.Config
} else {
} else if options.Project != "" {
configPath = filepath.Join(userConfigDir, options.Project+".yml")
} else {
path, err := os.Getwd()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
configPath = filepath.Join(path, defaultConfigFile)
}

switch options.Command {
Expand Down

0 comments on commit 01986eb

Please sign in to comment.