Skip to content

Commit

Permalink
add support for update command (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitWakchaure committed Oct 18, 2022
1 parent 2b47770 commit 45d5302
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 39 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.3
v2.1.0
6 changes: 5 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func NewApp(appConfig *config.AppConfig, updateConfig *software.UpdateConfig) *A
a.AppsDir = filepath.Join(config.GetUserHomeDir(), "Downloads")
}
WriteAppConfig(a.AppConfig)
software.PrintUpdateInfo(a.UpdateConfig)
return a
}

Expand Down Expand Up @@ -143,6 +142,11 @@ func (a *App) RunWithList(logLevel string, args []string) {
runExecutable(flogoApp, logLevel, args)
}

// Update will update the app to latest version released on Github
func (a *App) Update() {
software.Update(a.AppConfig)
}

// PrintVersion ...
func PrintVersion() {
fmt.Println("#> Run Flogo App")
Expand Down
2 changes: 1 addition & 1 deletion cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import (
)

func init() {
fmt.Println("Initializing docs...")
fmt.Println("#> Initializing docs...")
GENDOCS = true
}
2 changes: 1 addition & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var installCmd = &cobra.Command{
Use: "install",
Short: "Install the program",
Run: func(cmd *cobra.Command, args []string) {
software.Install(a.InstallPath)
software.Install("")
},
}

Expand Down
9 changes: 6 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ var rootCmd = &cobra.Command{
trace, _ := cmd.Flags().GetBool("trace")
list, _ := cmd.Flags().GetBool("list")
name, _ := cmd.Flags().GetString("name")
software.PrintUpdateInfo(a.UpdateConfig)
go func() {
updateConfig := software.CheckForUpdates()
software.WriteUpdateConfig(updateConfig)
updateConfig, err := software.CheckForUpdates()
if err == nil {
software.WriteUpdateConfig(updateConfig)
}
}()
logLevel := config.LogLevelInfo
if trace {
Expand Down Expand Up @@ -112,7 +115,7 @@ func initConfig() {
viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
fmt.Printf("i> Using config file: %s\n", viper.ConfigFileUsed())
fmt.Printf("i> Using config file at: %s\n\n", viper.ConfigFileUsed())
}

appsDir := viper.GetString("appsDir")
Expand Down
18 changes: 18 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/spf13/cobra"
)

// updateCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update the app with latest version",
Run: func(cmd *cobra.Command, args []string) {
a.Update()
},
}

func init() {
rootCmd.AddCommand(updateCmd)
}
2 changes: 2 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/abhijitWakchaure/run-flogo-app/app"
"github.com/abhijitWakchaure/run-flogo-app/software"
"github.com/spf13/cobra"
)

Expand All @@ -10,6 +11,7 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version info of the program",
Run: func(cmd *cobra.Command, args []string) {
software.PrintUpdateInfo(a.UpdateConfig)
app.PrintVersion()
},
}
Expand Down
2 changes: 2 additions & 0 deletions docs/run-flogo-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ run-flogo-app [flags]
-h, --help help for run-flogo-app
-l, --list List last 5 apps and choose a number to run
-n, --name string Run app with given (partial) name
-t, --trace Enable trace logs
```

### SEE ALSO
Expand All @@ -25,5 +26,6 @@ run-flogo-app [flags]
* [run-flogo-app delete](run-flogo-app_delete.md) - Delete all the flogo apps in apps dir
* [run-flogo-app install](run-flogo-app_install.md) - Install the program
* [run-flogo-app uninstall](run-flogo-app_uninstall.md) - Uninstall the program
* [run-flogo-app update](run-flogo-app_update.md) - Update the app with latest version
* [run-flogo-app version](run-flogo-app_version.md) - Print the version info of the program

18 changes: 18 additions & 0 deletions docs/run-flogo-app_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## run-flogo-app update

Update the app with latest version

```
run-flogo-app update [flags]
```

### Options

```
-h, --help help for update
```

### SEE ALSO

* [run-flogo-app](run-flogo-app.md) - Run the most recent flogo app from your apps dir

2 changes: 1 addition & 1 deletion manpages/run-flogo-app-config.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion manpages/run-flogo-app-delete.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion manpages/run-flogo-app-install.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down
2 changes: 1 addition & 1 deletion manpages/run-flogo-app-uninstall.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down
27 changes: 27 additions & 0 deletions manpages/run-flogo-app-update.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.nh
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
run-flogo-app-update - Update the app with latest version


.SH SYNOPSIS
.PP
\fBrun-flogo-app update [flags]\fP


.SH DESCRIPTION
.PP
Update the app with latest version


.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for update


.SH SEE ALSO
.PP
\fBrun-flogo-app(3)\fP
2 changes: 1 addition & 1 deletion manpages/run-flogo-app-version.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down
8 changes: 6 additions & 2 deletions manpages/run-flogo-app.3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nh
.TH "run-flogo-app" "3" "Aug 2022" "" ""
.TH "run-flogo-app" "3" "Oct 2022" "" ""

.SH NAME
.PP
Expand Down Expand Up @@ -33,7 +33,11 @@ Run the most recent flogo app from your configured apps dir. If the apps dir is
\fB-n\fP, \fB--name\fP=""
Run app with given (partial) name

.PP
\fB-t\fP, \fB--trace\fP[=false]
Enable trace logs


.SH SEE ALSO
.PP
\fBrun-flogo-app-config(3)\fP, \fBrun-flogo-app-delete(3)\fP, \fBrun-flogo-app-install(3)\fP, \fBrun-flogo-app-uninstall(3)\fP, \fBrun-flogo-app-version(3)\fP
\fBrun-flogo-app-config(3)\fP, \fBrun-flogo-app-delete(3)\fP, \fBrun-flogo-app-install(3)\fP, \fBrun-flogo-app-uninstall(3)\fP, \fBrun-flogo-app-update(3)\fP, \fBrun-flogo-app-version(3)\fP
Loading

0 comments on commit 45d5302

Please sign in to comment.