-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:web-of-things-open-source/tm-catalo…
…g-cli into main
- Loading branch information
Showing
23 changed files
with
735 additions
and
70 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/cmd" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteCmd represents the remote command | ||
var remoteCmd = &cobra.Command{ | ||
Use: "remote", | ||
Short: "Manage remote repositories", | ||
Long: `The command remote and its subcommands allow to manage the list of remote repositories and their settings. | ||
When no subcommand is given, defaults to list.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := cli.RemoteList() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
cmd.RootCmd.AddCommand(remoteCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// remoteCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// remoteCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteAddCmd represents the 'remote add' command | ||
var remoteAddCmd = &cobra.Command{ | ||
Use: "add [--type <type>] <name> (<config> | --file <configFileName>)", | ||
Short: "Add a remote repository", | ||
Long: `Add a remote repository to the tm-catalog-cli configuration file. Depending on the remote type, | ||
the config may be a simple string, like a URL, or a json file. | ||
--type is optional only if --file is used and the type is specified there. | ||
`, | ||
Args: cobra.RangeArgs(1, 2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
typ, err := cmd.Flags().GetString("type") | ||
if err != nil { | ||
cli.Stderrf("internal error: %v", err) | ||
os.Exit(1) | ||
} | ||
name := args[0] | ||
confStr := "" | ||
if len(args) > 1 { | ||
confStr = args[1] | ||
} | ||
|
||
confFile, err := cmd.Flags().GetString("file") | ||
if err != nil { | ||
cli.Stderrf("internal error: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
err = cli.RemoteAdd(name, typ, confStr, confFile) | ||
if err != nil { | ||
_ = cmd.Usage() | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteAddCmd) | ||
remoteAddCmd.Flags().StringP("type", "t", "", "type of remote to add") | ||
remoteAddCmd.Flags().StringP("file", "f", "", "name of the file to read remote config from") | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteRemoveCmd represents the 'remote remove' command | ||
var remoteRemoveCmd = &cobra.Command{ | ||
Use: "remove <name>", | ||
Short: "Remove the named remote repository from config", | ||
Long: `Remove the named remote repository from config`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := cli.RemoteRemove(args[0]) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteRemoveCmd) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteRenameCmd represents the 'remote show' command | ||
var remoteRenameCmd = &cobra.Command{ | ||
Use: "rename <old-name> <new-name>", | ||
Short: "Renames remote <old-name> to <new-name>", | ||
Long: `Renames remote <old-name> to <new-name>`, | ||
Args: cobra.ExactArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := cli.RemoteRename(args[0], args[1]) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteRenameCmd) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteSetConfigCmd represents the 'remote add' command | ||
var remoteSetConfigCmd = &cobra.Command{ | ||
Use: "set-config [--type <type>] <name> (<config> | --file <configFileName>)", | ||
Short: "Set config for a remote repository", | ||
Long: `Overwrite config of a remote repository. Depending on the remote type, | ||
the config may be a simple string, like a URL, or a json file. | ||
--type is optional only if --file is used and the type is specified there.`, | ||
Args: cobra.RangeArgs(1, 2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
typ, err := cmd.Flags().GetString("type") | ||
if err != nil { | ||
cli.Stderrf("internal error: %v", err) | ||
os.Exit(1) | ||
} | ||
name := args[0] | ||
confStr := "" | ||
if len(args) > 1 { | ||
confStr = args[1] | ||
} | ||
|
||
confFile, err := cmd.Flags().GetString("file") | ||
if err != nil { | ||
cli.Stderrf("internal error: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
err = cli.RemoteSetConfig(name, typ, confStr, confFile) | ||
if err != nil { | ||
_ = cmd.Usage() | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteSetConfigCmd) | ||
remoteSetConfigCmd.Flags().StringP("type", "t", "", "type of remote to add") | ||
remoteSetConfigCmd.Flags().StringP("file", "f", "", "name of the file to read remote config from") | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteSetDefaultCmd represents the 'remote set-default' command | ||
var remoteSetDefaultCmd = &cobra.Command{ | ||
Use: "set-default <name>", | ||
Short: "Set named remote repository as default", | ||
Long: `Set named remote repository as default`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := cli.RemoteSetDefault(args[0]) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteSetDefaultCmd) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package remote | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/web-of-things-open-source/tm-catalog-cli/internal/app/cli" | ||
) | ||
|
||
// remoteShowCmd represents the 'remote show' command | ||
var remoteShowCmd = &cobra.Command{ | ||
Use: "show <name>", | ||
Short: "Shows settings for the remote <name>", | ||
Long: `Shows settings for the remote <name>`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := cli.RemoteShow(args[0]) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
remoteCmd.AddCommand(remoteShowCmd) | ||
} |
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
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
Oops, something went wrong.