ledo init

This commit is contained in:
2021-11-20 11:34:31 +01:00
parent 8a91f699b8
commit da41b5820b
16 changed files with 336 additions and 1 deletions

View File

@ -34,6 +34,11 @@ func InitCommand(ctx *cli.Context) *LedoContext {
modeYml = ".jz-mode"
}
if _, err := os.Stat(configYml); err != nil {
fmt.Printf("Config file not found. Please run ledo init\n")
os.Exit(1)
}
mode := mode.InitMode(modeYml, configYml)
c.Mode = mode
@ -56,6 +61,18 @@ func InitCommand(ctx *cli.Context) *LedoContext {
return &c
}
func LoadConfigFile() (*config.LedoFile, error) {
configYml := ".ledo.yml"
if _, err := os.Stat(configYml); err != nil {
nilCfg := &config.LedoFile{}
return nilCfg, err
}
cfg, _ := config.NewLedoFile(configYml)
return cfg, nil
}
func (lx *LedoContext) ExecCmd(cmd string, cmdArgs []string) error {
fmt.Printf("Execute: %v %v\n", cmd, strings.Join(cmdArgs, " "))
command := exec.Command(cmd, cmdArgs...)