From 03ef288abc54ec0c1b871e51820b877ce4725ecc Mon Sep 17 00:00:00 2001 From: maxlandon <maximelandon@gmail.com> Date: Mon, 4 Dec 2023 08:30:39 +0100 Subject: [PATCH 1/2] Add a Data map[string]any field to store arbitrary data for a command. --- command.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command.go b/command.go index 11a3e9c9..9c8a0545 100644 --- a/command.go +++ b/command.go @@ -111,6 +111,11 @@ type Command struct { // command does not define one. Version string + // Data are key/value pairs of arbitrary types that can be used by applications or "plugin" libraries + // that wish to store and use data associated with a given command. This data will thus share the same + // lifetime as the command itself. + Data map[string]any + // The *Run functions are executed in the following order: // * PersistentPreRun() // * PreRun() From 62781eb0a456e792a72d123e155b9dc871326fec Mon Sep 17 00:00:00 2001 From: maxlandon <maximelandon@gmail.com> Date: Tue, 11 Feb 2025 16:43:58 +0000 Subject: [PATCH 2/2] Use interface{} instead of any for backward compatibility --- command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command.go b/command.go index 9c8a0545..a068ccf0 100644 --- a/command.go +++ b/command.go @@ -114,7 +114,7 @@ type Command struct { // Data are key/value pairs of arbitrary types that can be used by applications or "plugin" libraries // that wish to store and use data associated with a given command. This data will thus share the same // lifetime as the command itself. - Data map[string]any + Data map[string]interface{} // The *Run functions are executed in the following order: // * PersistentPreRun()