Skip to content

Vault cli #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions cmd/aem/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ func (c *CLI) contentDownloadCmd() *cobra.Command {
c.Error(err)
return
}
pid, _ := cmd.Flags().GetString("pid")
if pid == "" {
pid = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
targetPID, _ := cmd.Flags().GetString("target-pid")
if targetPID == "" {
targetPID = fmt.Sprintf("aemc:content-download:%s-SNAPSHOT", timex.FileTimestampForNow())
}
targetFile, _ := cmd.Flags().GetString("target-file")
filterRoots := determineFilterRoots(cmd)
filterFile, _ := cmd.Flags().GetString("filter-file")
clean, _ := cmd.Flags().GetBool("clean")
if err = c.aem.ContentManager().Download(instance, targetFile, clean, pkg.PackageCreateOpts{
PID: pid,
PID: targetPID,
FilterRoots: filterRoots,
FilterFile: filterFile,
}); err != nil {
Expand All @@ -96,13 +96,13 @@ func (c *CLI) contentDownloadCmd() *cobra.Command {
c.Changed("content downloaded")
},
}
cmd.Flags().String("pid", "", "ID (group:name:version) for downloaded package")
cmd.Flags().StringP("target-file", "t", "", "Target file path for downloaded package")
cmd.Flags().StringP("target-pid", "p", "", "ID (group:name:version) for downloaded package")
cmd.Flags().StringP("target-file", "t", "", "File path for downloaded package")
_ = cmd.MarkFlagRequired("target-file")
cmd.Flags().StringSliceP("filter-roots", "r", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "f", "", "Vault filter file path")
cmd.Flags().StringSliceP("filter-roots", "g", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "h", "", "Vault filter file path")
cmd.MarkFlagsOneRequired("filter-roots", "filter-file")
cmd.Flags().Bool("clean", false, "Normalize content after downloading")
cmd.Flags().BoolP("clean", "c", false, "Normalize content after downloading")
return cmd
}

Expand Down Expand Up @@ -157,14 +157,14 @@ func (c *CLI) contentPullCmd() *cobra.Command {
},
}
cmd.Flags().StringP("dir", "d", "", "JCR root path")
cmd.Flags().String("file", "", "Local file path")
cmd.Flags().StringP("file", "f", "", "Local file path")
cmd.Flags().StringP("path", "p", "", "JCR root path or local file path")
cmd.MarkFlagsMutuallyExclusive("dir", "file", "path")
cmd.Flags().StringSliceP("filter-roots", "r", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "f", "", "Vault filter file path")
cmd.MarkFlagsOneRequired("dir", "file", "path")
cmd.Flags().StringSliceP("filter-roots", "g", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "h", "", "Vault filter file path")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"h" should be reserved for help

cmd.MarkFlagsMutuallyExclusive("filter-roots", "filter-file")
cmd.Flags().Bool("clean", false, "Normalize content after downloading")
cmd.Flags().Bool("replace", false, "Replace content after downloading")
cmd.Flags().BoolP("clean", "c", false, "Normalize content after downloading")
cmd.Flags().BoolP("replace", "r", false, "Replace content after downloading")
return cmd
}

Expand Down Expand Up @@ -200,7 +200,7 @@ func (c *CLI) contentPushCmd() *cobra.Command {
filterRoots := determineFilterRoots(cmd)
filterRootExcludes := determineFilterRootExcludes(cmd)
clean, _ := cmd.Flags().GetBool("clean")
filterMode := determineFilterMode(cmd)
filterMode, _ := cmd.Flags().GetString("filter-mode")
if err = c.aem.ContentManager().Push(instances, clean, pkg.PackageCreateOpts{
PID: fmt.Sprintf("aemc:content-push:%s-SNAPSHOT", timex.FileTimestampForNow()),
FilterRoots: filterRoots,
Expand All @@ -223,8 +223,8 @@ func (c *CLI) contentPushCmd() *cobra.Command {
cmd.Flags().StringP("file", "f", "", "Local file path")
cmd.Flags().StringP("path", "p", "", "JCR root path or local file path")
cmd.MarkFlagsOneRequired("dir", "file", "path")
cmd.Flags().Bool("clean", false, "Normalize content while uploading")
cmd.Flags().Bool("update", false, "Existing content on running instance is updated, new content is added and none is deleted")
cmd.Flags().BoolP("clean", "c", false, "Normalize content while uploading")
cmd.Flags().StringP("filter-mode", "m", "", "Override default filter model")
return cmd
}

Expand Down Expand Up @@ -261,10 +261,10 @@ func (c *CLI) contentCopyCmd() *cobra.Command {
cmd.Flags().StringSliceP("instance-target-url", "u", []string{}, "Destination instance URL")
cmd.Flags().StringSliceP("instance-target-id", "i", []string{}, "Destination instance ID")
cmd.MarkFlagsOneRequired("instance-target-url", "instance-target-id")
cmd.Flags().StringSliceP("filter-roots", "r", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "f", "", "Vault filter file path")
cmd.Flags().StringSliceP("filter-roots", "g", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "h", "", "Vault filter file path")
cmd.MarkFlagsOneRequired("filter-roots", "filter-file")
cmd.Flags().Bool("clean", false, "Normalize content while copying")
cmd.Flags().BoolP("clean", "c", false, "Normalize content while copying")
return cmd
}

Expand Down Expand Up @@ -373,11 +373,3 @@ func determineFilterRootExcludes(cmd *cobra.Command) []string {
}
return filterRootExcludes
}

func determineFilterMode(cmd *cobra.Command) string {
update, _ := cmd.Flags().GetBool("update")
if update {
return "update"
}
return ""
}
6 changes: 3 additions & 3 deletions cmd/aem/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ func (c *CLI) pkgCreateCmd() *cobra.Command {
},
}
cmd.Flags().String("pid", "", "ID (group:name:version)'")
cmd.Flags().StringSliceP("filter-roots", "r", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "F", "", "Vault filter file path")
cmd.Flags().StringSliceP("filter-roots", "g", []string{}, "Vault filter root paths")
cmd.Flags().StringP("filter-file", "h", "", "Vault filter file path")
cmd.MarkFlagsMutuallyExclusive("filter-roots", "filter-file")
cmd.Flags().BoolP("force", "f", false, "Create even when already created")
_ = cmd.MarkFlagRequired("pid")
Expand Down Expand Up @@ -607,7 +607,7 @@ func (c *CLI) pkgUpdateCmd() *cobra.Command {
}
cmd.Flags().String("pid", "", "ID (group:name:version)'")
cmd.Flags().String("path", "", "Remote repository path")
cmd.Flags().StringSliceP("filter-roots", "r", []string{}, "Vault filter root paths")
cmd.Flags().StringSliceP("filter-roots", "g", []string{}, "Vault filter root paths")
cmd.MarkFlagsOneRequired("pid", "path")
cmd.MarkFlagsMutuallyExclusive("pid", "path")
return cmd
Expand Down
Loading