From 3acb20a40fa4f7946d5efa6ada0fb780ed71d96f Mon Sep 17 00:00:00 2001 From: Andrew Woodlee Date: Sun, 23 Feb 2025 15:42:50 -0600 Subject: [PATCH] v0.8.1 --- .../unreleased/Added-20250220-144549.yaml | 3 + .../unreleased/Added-20250220-145014.yaml | 3 + .../unreleased/Added-20250220-145245.yaml | 3 + .../unreleased/Added-20250221-003012.yaml | 3 + .../unreleased/Changed-20250223-153012.yaml | 3 + .../unreleased/Changed-20250223-153305.yaml | 3 + .../unreleased/Fixed-20250220-144843.yaml | 3 + .gitignore | 8 +- pkg/backy/commandtype_enumer.go | 141 ++++++++++++++++++ pkg/backy/tools.go | 8 + 10 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 .changes/unreleased/Added-20250220-144549.yaml create mode 100644 .changes/unreleased/Added-20250220-145014.yaml create mode 100644 .changes/unreleased/Added-20250220-145245.yaml create mode 100644 .changes/unreleased/Added-20250221-003012.yaml create mode 100644 .changes/unreleased/Changed-20250223-153012.yaml create mode 100644 .changes/unreleased/Changed-20250223-153305.yaml create mode 100644 .changes/unreleased/Fixed-20250220-144843.yaml create mode 100644 pkg/backy/commandtype_enumer.go create mode 100644 pkg/backy/tools.go diff --git a/.changes/unreleased/Added-20250220-144549.yaml b/.changes/unreleased/Added-20250220-144549.yaml new file mode 100644 index 0000000..0499561 --- /dev/null +++ b/.changes/unreleased/Added-20250220-144549.yaml @@ -0,0 +1,3 @@ +kind: Added +body: '`list` command with subcommands `cmds` and `lists`' +time: 2025-02-20T14:45:49.562361581-06:00 diff --git a/.changes/unreleased/Added-20250220-145014.yaml b/.changes/unreleased/Added-20250220-145014.yaml new file mode 100644 index 0000000..7389d93 --- /dev/null +++ b/.changes/unreleased/Added-20250220-145014.yaml @@ -0,0 +1,3 @@ +kind: Added +body: Deprecation and unsupported warnings for old config keys +time: 2025-02-20T14:50:14.048452348-06:00 diff --git a/.changes/unreleased/Added-20250220-145245.yaml b/.changes/unreleased/Added-20250220-145245.yaml new file mode 100644 index 0000000..6b98bd8 --- /dev/null +++ b/.changes/unreleased/Added-20250220-145245.yaml @@ -0,0 +1,3 @@ +kind: Added +body: CLI flag `--cmdStdOut` to output command's stdout/stderr to stdout +time: 2025-02-20T14:52:45.030582408-06:00 diff --git a/.changes/unreleased/Added-20250221-003012.yaml b/.changes/unreleased/Added-20250221-003012.yaml new file mode 100644 index 0000000..786852e --- /dev/null +++ b/.changes/unreleased/Added-20250221-003012.yaml @@ -0,0 +1,3 @@ +kind: Added +body: Command type `remoteScript`. See docs for more info. +time: 2025-02-21T00:30:12.276616792-06:00 diff --git a/.changes/unreleased/Changed-20250223-153012.yaml b/.changes/unreleased/Changed-20250223-153012.yaml new file mode 100644 index 0000000..fae6bde --- /dev/null +++ b/.changes/unreleased/Changed-20250223-153012.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: change to enums for Command type +time: 2025-02-23T15:30:12.033359922-06:00 diff --git a/.changes/unreleased/Changed-20250223-153305.yaml b/.changes/unreleased/Changed-20250223-153305.yaml new file mode 100644 index 0000000..4297843 --- /dev/null +++ b/.changes/unreleased/Changed-20250223-153305.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: Cache now stores resources by URL hash for ease-of-lookup +time: 2025-02-23T15:33:05.33444642-06:00 diff --git a/.changes/unreleased/Fixed-20250220-144843.yaml b/.changes/unreleased/Fixed-20250220-144843.yaml new file mode 100644 index 0000000..5cab469 --- /dev/null +++ b/.changes/unreleased/Fixed-20250220-144843.yaml @@ -0,0 +1,3 @@ +kind: Fixed +body: Local command's `dir` config key resolved to full path +time: 2025-02-20T14:48:43.475300515-06:00 diff --git a/.gitignore b/.gitignore index 4eae6db..c1e6dc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ -+.changie.yaml -+.changes/* +!.changie.yaml +!.changes/** dist/ .codegpt *.log *.sh -*.yaml -*.yml +./*.yaml +./*.yml diff --git a/pkg/backy/commandtype_enumer.go b/pkg/backy/commandtype_enumer.go new file mode 100644 index 0000000..d27e3fe --- /dev/null +++ b/pkg/backy/commandtype_enumer.go @@ -0,0 +1,141 @@ +// Code generated by "enumer -linecomment -yaml -text -json -type=CommandType"; DO NOT EDIT. + +package backy + +import ( + "encoding/json" + "fmt" + "strings" +) + +const _CommandTypeName = "scriptscriptFileremoteScriptpackageuser" + +var _CommandTypeIndex = [...]uint8{0, 0, 6, 16, 28, 35, 39} + +const _CommandTypeLowerName = "scriptscriptfileremotescriptpackageuser" + +func (i CommandType) String() string { + if i < 0 || i >= CommandType(len(_CommandTypeIndex)-1) { + return fmt.Sprintf("CommandType(%d)", i) + } + return _CommandTypeName[_CommandTypeIndex[i]:_CommandTypeIndex[i+1]] +} + +// An "invalid array index" compiler error signifies that the constant values have changed. +// Re-run the stringer command to generate them again. +func _CommandTypeNoOp() { + var x [1]struct{} + _ = x[Default-(0)] + _ = x[Script-(1)] + _ = x[ScriptFile-(2)] + _ = x[RemoteScript-(3)] + _ = x[Package-(4)] + _ = x[User-(5)] +} + +var _CommandTypeValues = []CommandType{Default, Script, ScriptFile, RemoteScript, Package, User} + +var _CommandTypeNameToValueMap = map[string]CommandType{ + _CommandTypeName[0:0]: Default, + _CommandTypeLowerName[0:0]: Default, + _CommandTypeName[0:6]: Script, + _CommandTypeLowerName[0:6]: Script, + _CommandTypeName[6:16]: ScriptFile, + _CommandTypeLowerName[6:16]: ScriptFile, + _CommandTypeName[16:28]: RemoteScript, + _CommandTypeLowerName[16:28]: RemoteScript, + _CommandTypeName[28:35]: Package, + _CommandTypeLowerName[28:35]: Package, + _CommandTypeName[35:39]: User, + _CommandTypeLowerName[35:39]: User, +} + +var _CommandTypeNames = []string{ + _CommandTypeName[0:0], + _CommandTypeName[0:6], + _CommandTypeName[6:16], + _CommandTypeName[16:28], + _CommandTypeName[28:35], + _CommandTypeName[35:39], +} + +// CommandTypeString retrieves an enum value from the enum constants string name. +// Throws an error if the param is not part of the enum. +func CommandTypeString(s string) (CommandType, error) { + if val, ok := _CommandTypeNameToValueMap[s]; ok { + return val, nil + } + + if val, ok := _CommandTypeNameToValueMap[strings.ToLower(s)]; ok { + return val, nil + } + return 0, fmt.Errorf("%s does not belong to CommandType values", s) +} + +// CommandTypeValues returns all values of the enum +func CommandTypeValues() []CommandType { + return _CommandTypeValues +} + +// CommandTypeStrings returns a slice of all String values of the enum +func CommandTypeStrings() []string { + strs := make([]string, len(_CommandTypeNames)) + copy(strs, _CommandTypeNames) + return strs +} + +// IsACommandType returns "true" if the value is listed in the enum definition. "false" otherwise +func (i CommandType) IsACommandType() bool { + for _, v := range _CommandTypeValues { + if i == v { + return true + } + } + return false +} + +// MarshalJSON implements the json.Marshaler interface for CommandType +func (i CommandType) MarshalJSON() ([]byte, error) { + return json.Marshal(i.String()) +} + +// UnmarshalJSON implements the json.Unmarshaler interface for CommandType +func (i *CommandType) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return fmt.Errorf("CommandType should be a string, got %s", data) + } + + var err error + *i, err = CommandTypeString(s) + return err +} + +// MarshalText implements the encoding.TextMarshaler interface for CommandType +func (i CommandType) MarshalText() ([]byte, error) { + return []byte(i.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for CommandType +func (i *CommandType) UnmarshalText(text []byte) error { + var err error + *i, err = CommandTypeString(string(text)) + return err +} + +// MarshalYAML implements a YAML Marshaler for CommandType +func (i CommandType) MarshalYAML() (interface{}, error) { + return i.String(), nil +} + +// UnmarshalYAML implements a YAML Unmarshaler for CommandType +func (i *CommandType) UnmarshalYAML(unmarshal func(interface{}) error) error { + var s string + if err := unmarshal(&s); err != nil { + return err + } + + var err error + *i, err = CommandTypeString(s) + return err +} diff --git a/pkg/backy/tools.go b/pkg/backy/tools.go new file mode 100644 index 0000000..374d9f4 --- /dev/null +++ b/pkg/backy/tools.go @@ -0,0 +1,8 @@ +//go:build tools + +package backy + +import ( + // Protect this entry in go.mod from being removed by go mod tidy. + _ "github.com/dmarkham/enumer" +)