feat: Use .smug.yml as a default configuration file

master
Ivan 2 years ago committed by GitHub
parent 9097aaee7d
commit f5c5c51f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,8 @@
session: smug
root: .
windows:
- name: code
commands:
- go test ./...

@ -151,7 +151,8 @@ xyz@localhost:~$ smug start -f ./project.yml -w window1 -w window2
## Configuration ## 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 ### Examples

@ -47,6 +47,8 @@ Examples:
$ smug print > ~/.config/smug/blog.yml $ smug print > ~/.config/smug/blog.yml
`, version, FileUsage, WindowsUsage, AttachUsage, InsideCurrentSessionUsage, DebugUsage, DetachUsage) `, version, FileUsage, WindowsUsage, AttachUsage, InsideCurrentSessionUsage, DebugUsage, DetachUsage)
const defaultConfigFile = ".smug.yml"
func newLogger(path string) *log.Logger { func newLogger(path string) *log.Logger {
logFile, err := os.Create(filepath.Join(path, "smug.log")) logFile, err := os.Create(filepath.Join(path, "smug.log"))
if err != nil { if err != nil {
@ -87,8 +89,15 @@ func main() {
var configPath string var configPath string
if options.Config != "" { if options.Config != "" {
configPath = options.Config configPath = options.Config
} else { } else if options.Project != "" {
configPath = filepath.Join(userConfigDir, options.Project+".yml") 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 { switch options.Command {

Loading…
Cancel
Save