feat: added kwargs and flags to pass to plugins
This commit is contained in:
parent
dc6a141ca1
commit
42c8fd7c1a
6 changed files with 95 additions and 7 deletions
|
|
@ -9,11 +9,16 @@ import (
|
|||
"strings"
|
||||
|
||||
"git.towk2.me/towk/makeshift/internal/archive"
|
||||
"git.towk2.me/towk/makeshift/internal/kwargs"
|
||||
"git.towk2.me/towk/makeshift/pkg/client"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
pluginArgs []string
|
||||
pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{}
|
||||
)
|
||||
var downloadCmd = cobra.Command{
|
||||
Use: "download",
|
||||
Example: `
|
||||
|
|
@ -64,6 +69,12 @@ var downloadCmd = cobra.Command{
|
|||
if len(profileIDs) > 0 {
|
||||
query += "&profiles=" + url.QueryEscape(strings.Join(profileIDs, ","))
|
||||
}
|
||||
if len(pluginArgs) > 0 {
|
||||
query += "&args=" + url.QueryEscape(strings.Join(pluginArgs, ","))
|
||||
}
|
||||
if len(pluginKWArgs) > 0 {
|
||||
query += "&kwargs=" + url.QueryEscape(pluginKWArgs.String())
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
Str("host", host).
|
||||
|
|
@ -287,6 +298,8 @@ func init() {
|
|||
downloadCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
||||
downloadCmd.Flags().StringSlice("profiles", []string{}, "Set the profile(s) to use to populate data store")
|
||||
downloadCmd.Flags().StringSlice("plugins", []string{}, "Set the plugin(s) to run before downloading files")
|
||||
downloadCmd.Flags().StringSlice("plugin-args", []string{}, "Set the argument list to pass to plugin(s)")
|
||||
downloadCmd.Flags().Var(&pluginKWArgs, "plugin-kwargs", "Set the argument map to pass to plugin(s)")
|
||||
downloadCmd.Flags().BoolP("extract", "x", false, "Set whether to extract archive locally after downloading")
|
||||
downloadCmd.Flags().BoolP("remove-archive", "r", false, "Set whether to remove the archive after extracting (used with '--extract' flag)")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue