-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable downloading recipe from official repository (#28)
* Enable downloading recipe from official repository * Use flags in rollback and install commands * Allow JSON recipes * Test loading recipe from URL * Polish tests
- Loading branch information
Showing
30 changed files
with
782 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/pkosiec/terminer/internal/printer" | ||
"github.com/pkosiec/terminer/internal/recipecmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// installCmd represents the install command | ||
var installCmd = &cobra.Command{ | ||
Use: "install [file path or URL]", | ||
Short: "Installs a recipe from given path or URL", | ||
Long: `Install command installs a recipe from a local or remote file. | ||
Provide a relative or absolute path to a YAML file with recipe | ||
or an URL to download it. | ||
Use: "install [recipe name]", | ||
Short: "Installs a recipe from official repository, given path or URL", | ||
Long: `Install command installs a recipe from the official recipe repository. | ||
You can use additional flags to install a recipe from a local or remote file. | ||
Examples: | ||
terminer install ./recipe.yaml | ||
terminer install /Users/sample-user/recipe.yaml | ||
terminer install https://example.com/recipe.yaml | ||
terminer install zsh-starter | ||
terminer install -f ./recipe.yaml | ||
terminer install --file /Users/sample-user/recipe.yml | ||
terminer install -u https://example.com/recipe.yaml | ||
terminer install --url http://foo.bar/recipe.yml | ||
`, | ||
Args: validateInstallRollbackArgs, | ||
RunE: runInstall, | ||
Args: recipecmd.ValidateArgs, | ||
RunE: recipecmd.Run(recipecmd.Install), | ||
DisableFlagsInUseLine: true, | ||
} | ||
|
||
func init() { | ||
recipecmd.SupportFlags(installCmd) | ||
rootCmd.AddCommand(installCmd) | ||
} | ||
|
||
func runInstall(cmd *cobra.Command, args []string) error { | ||
p := printer.New() | ||
i, err := setupInstaller(args[0], p) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = i.Install() | ||
p.Result(err) | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/pkosiec/terminer/internal/printer" | ||
"github.com/pkosiec/terminer/internal/recipecmd" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// rollbackCmd represents the rollback command | ||
var rollbackCmd = &cobra.Command{ | ||
Use: "rollback [file path or URL]", | ||
Short: "Rollbacks a recipe from given path or URL", | ||
Long: `Rollback command rollbacks a recipe from a local or remote file. | ||
Provide a relative or absolute path to a YAML file with recipe | ||
or an URL to download it. | ||
Use: "rollback [recipe name]", | ||
Short: "Rollbacks a recipe from official repository, given path or URL", | ||
Long: `Rollback command uninstalls a recipe from the official recipe repository. | ||
You can use additional flags to rollback a recipe from a local or remote file. | ||
Examples: | ||
terminer rollback ./recipe.yaml | ||
terminer rollback /Users/sample-user/recipe.yaml | ||
terminer rollback https://example.com/recipe.yaml | ||
terminer rollback zsh-starter | ||
terminer rollback -f ./recipe.yaml | ||
terminer rollback --file /Users/sample-user/recipe.yml | ||
terminer rollback -u https://example.com/recipe.yaml | ||
terminer rollback --url http://foo.bar/recipe.yml | ||
`, | ||
Args: validateInstallRollbackArgs, | ||
RunE: runRollback, | ||
Args: recipecmd.ValidateArgs, | ||
RunE: recipecmd.Run(recipecmd.Rollback), | ||
DisableFlagsInUseLine: true, | ||
} | ||
|
||
func init() { | ||
recipecmd.SupportFlags(rollbackCmd) | ||
rootCmd.AddCommand(rollbackCmd) | ||
} | ||
|
||
func runRollback(cmd *cobra.Command, args []string) error { | ||
p := printer.New() | ||
i, err := setupInstaller(args[0], p) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = i.Rollback() | ||
p.Result(err) | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.