1- package main
1+ package config
22
33import (
44 "os"
55
66 "github.com/pelletier/go-toml"
77)
88
9- const configFile = "devshell.toml"
9+ // FileName ...
10+ const FileName = "devshell.toml"
1011
11- type configBash struct {
12+ // Bash ...
13+ type Bash struct {
1214 Extra string `toml:"extra,omitempty"`
1315 Interactive string `toml:"interactive,omitempty"`
1416}
1517
16- type configCommand struct {
18+ // Command ...
19+ type Command struct {
1720 Alias string `toml:"alias,omitempty"`
1821 Command string `toml:"command,omitempty"`
1922 Help string `toml:"help,omitempty"`
2023 Name string `toml:"name"`
2124 Package string `toml:"package,omitempty"`
2225}
2326
24- type config struct {
27+ // Config ...
28+ type Config struct {
2529 Name string `toml:"name"`
2630 Packages []string `toml:"packages"`
2731 Motd * string `toml:"motd"`
2832 Env map [string ]interface {} `toml:"env"`
29- Bash configBash `toml:"bash,omitempty"`
30- Commands []configCommand `toml:"commands"`
33+ Bash Bash `toml:"bash,omitempty"`
34+ Commands []Command `toml:"commands"`
3135}
3236
33- func configLoad (path string ) (* config , error ) {
37+ // Load ...
38+ func Load (path string ) (* Config , error ) {
3439 r , err := os .Open (path )
3540 if err != nil {
3641 return nil , err
3742 }
3843
39- c := & config {}
44+ c := & Config {}
4045 err = toml .NewDecoder (r ).Decode (c )
4146 if err != nil {
4247 return nil , err
@@ -45,7 +50,8 @@ func configLoad(path string) (*config, error) {
4550 return c , err
4651}
4752
48- func configPrint (c * config ) string {
53+ // Print ...
54+ func Print (c * Config ) string {
4955 b , err := toml .Marshal (c )
5056 if err != nil {
5157 panic (err ) // should never happen
0 commit comments