Skip to content

Commit

Permalink
Ian: Simplify the tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
Theotime Leveque committed May 9, 2018
1 parent 8077f75 commit b9a0195
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
4 changes: 2 additions & 2 deletions backend/env/setup.go → backend/env/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
pm "github.com/thylong/ian/backend/package-managers"
)

// Setup installs Ian and configuration Ian's environment.
func Setup(OSPackageManager pm.PackageManager) {
// Restore installs Ian and configuration Ian's environment.
func Restore(OSPackageManager pm.PackageManager) {
if _, err := os.Stat(OSPackageManager.GetExecPath()); err != nil {
log.Infoln("Installing OS package manager...")
if err = OSPackageManager.Setup(); err != nil {
Expand Down
18 changes: 4 additions & 14 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ var allCmdParam bool
func init() {
RootCmd.AddCommand(envCmd)

envUpdateCmd.Flags().BoolVarP(&allCmdParam, "all", "a", false, "Run update on all Package managers")
envUpgradeCmd.Flags().BoolVarP(&allCmdParam, "all", "a", false, "Run upgrade on all Package managers")
envCmd.AddCommand(
RootCmd.AddCommand(
envAddCmd,
envRemoveCmd,
envShowCmd,
Expand Down Expand Up @@ -61,7 +59,7 @@ var envAddCmd = &cobra.Command{
}

var envRemoveCmd = &cobra.Command{
Use: "remove",
Use: "rm",
Short: "Remove package(s) to ian configuration",
Long: `Remove package(s) to ian env.yml.`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -112,11 +110,7 @@ var envUpdateCmd = &cobra.Command{
Long: `Update the development environment.`,
Run: func(cmd *cobra.Command, args []string) {
go spinner()
if allCmdParam {
pm.UpdateAllPackageManagers()
return
}
OSPackageManager.UpdateAll()
pm.UpdateAllPackageManagers()
},
}

Expand All @@ -126,11 +120,7 @@ var envUpgradeCmd = &cobra.Command{
Long: `Upgrade the development environment.`,
Run: func(cmd *cobra.Command, args []string) {
go spinner()
if allCmdParam {
pm.UpgradeAllPackageManagers()
return
}
OSPackageManager.UpgradeAll()
pm.UpgradeAllPackageManagers()
},
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/setup.go → cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
)

func init() {
RootCmd.AddCommand(setupCmd)
RootCmd.AddCommand(restore)
}

// setupCmd represents the setup command
var setupCmd = &cobra.Command{
Use: "setup",
Short: "Set up ian configuration",
// restore represents the setup command
var restore = &cobra.Command{
Use: "restore",
Short: "Restore ian configuration",
Long: `Ian requires you to be able to interact with Github through Git CLI.`,
Run: func(cmd *cobra.Command, args []string) {
env.Setup(OSPackageManager)
env.Restore(OSPackageManager)

log.Infoln("Great! You're ready to start using Ian.")
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/self_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ var selfUpdateCmd = &cobra.Command{
// Removing backup
os.Remove(destBackup)

log.Errorf("ian updated with success to version %s\n", remoteVersion)
log.Infof("ian updated with success to version %s\n", remoteVersion)
} else {
log.Errorln("ian is up to date")
log.Infoln("ian is up to date")
}
},
}

0 comments on commit b9a0195

Please sign in to comment.