Skip to content

Commit

Permalink
feat(proxy): add trash flag (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Dec 16, 2023
1 parent 8984128 commit d208d8a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/command/shrink-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var shrinkShortFlags = cobrass.KnownByCollection{
// shrink specific:
//
"output": "o",
"trash": "t",
"mode": "m",
// families:
//
Expand Down Expand Up @@ -169,6 +170,26 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob
},
)

// --trash(t)
//
const (
defaultTrashPath = ""
)

paramSet.BindValidatedString(
newShrinkFlagInfoWithShort(
xi18n.Text(i18n.ShrinkCmdTrashPathParamUsageTemplData{}),
defaultTrashPath,
),
&paramSet.Native.TrashPath, func(s string, f *pflag.Flag) error {
if f.Changed && !utils.FolderExists(s) {
return i18n.NewOutputPathDoesNotExistError(s)
}

return nil
},
)

// --mode(m)
//
const (
Expand Down
30 changes: 30 additions & 0 deletions src/app/command/shrink-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ var _ = Describe("ShrinkCmd", Ordered, func() {

expectValidShrinkCmdInvocation(entry)
})

It("🧪 should: execute successfully", func() {
entry := &shrinkTE{
directory: l10nPath,
commandTE: commandTE{
message: "with general long form parameters",
args: []string{
"--trash", l10nPath,
},
configPath: configPath,
},
}

expectValidShrinkCmdInvocation(entry)
})
})

When("with general short form parameters", func() {
Expand All @@ -222,5 +237,20 @@ var _ = Describe("ShrinkCmd", Ordered, func() {

expectValidShrinkCmdInvocation(entry)
})

It("🧪 should: execute successfully", func() {
entry := &shrinkTE{
directory: l10nPath,
commandTE: commandTE{
message: "with general short form parameters",
args: []string{
"-t", l10nPath,
},
configPath: configPath,
},
}

expectValidShrinkCmdInvocation(entry)
})
})
})
1 change: 1 addition & 0 deletions src/app/proxy/image-defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type ShrinkParameterSet struct {
ThirdPartySet
//
OutputPath string
TrashPath string
ModeEn assistant.EnumValue[ModeEnum]
}

Expand Down
14 changes: 14 additions & 0 deletions src/i18n/messages-command.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ func (td ShrinkCmdOutputPathParamUsageTemplData) Message() *i18n.Message {
}
}

// ShrinkCmdTrashPathParamUsageTemplData
// 🧊
type ShrinkCmdTrashPathParamUsageTemplData struct {
pixaTemplData
}

func (td ShrinkCmdTrashPathParamUsageTemplData) Message() *i18n.Message {
return &i18n.Message{
ID: "shrink-cmd-trash-path.param-usage",
Description: "shrink trash path indicates the path where old items are moved to",
Other: "trash indicates where deleted items are moved to",
}
}

// ShrinkCmdModeParamUsageTemplData
// 🧊
type ShrinkCmdModeParamUsageTemplData struct {
Expand Down

0 comments on commit d208d8a

Please sign in to comment.