forked from toolshed/abra
refactor: use app getting instead of boilerplate
This commit is contained in:
@ -31,23 +31,13 @@ var appBackupCommand = &cli.Command{
|
||||
Flags: []cli.Flag{backupAllServicesFlag},
|
||||
ArgsUsage: "<service>",
|
||||
Action: func(c *cli.Context) error {
|
||||
appName := internal.ValidateAppNameArg(c)
|
||||
app := internal.ValidateApp(c)
|
||||
|
||||
if c.Args().Get(1) != "" && backupAllServices {
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("cannot use '<service>' and '--all' together"))
|
||||
}
|
||||
|
||||
appFiles, err := config.LoadAppFiles("")
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
appEnv, err := config.GetApp(appFiles, appName)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
abraSh := path.Join(config.ABRA_DIR, "apps", appEnv.Type, "abra.sh")
|
||||
abraSh := path.Join(config.ABRA_DIR, "apps", app.Type, "abra.sh")
|
||||
if _, err := os.Stat(abraSh); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
logrus.Fatalf("'%s' does not exist?", abraSh)
|
||||
@ -71,7 +61,7 @@ var appBackupCommand = &cli.Command{
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(bytes), execCmd) {
|
||||
logrus.Fatalf("%s doesn't have a '%s' function", appEnv.Type, execCmd)
|
||||
logrus.Fatalf("%s doesn't have a '%s' function", app.Type, execCmd)
|
||||
}
|
||||
|
||||
sourceAndExec := fmt.Sprintf("%s; %s", sourceCmd, execCmd)
|
||||
|
Reference in New Issue
Block a user