diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3b3e0f..f44599a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,5 @@
# Changelog
-## [0.1.0] - 2026-02-28
-
-- ✨ Move CLI commands to cli/ package for extensibility
-- Export RootCmd, DropCmd, and ConfigCmd for custom app creation
-
## [0.0.11] - 2026-02-13
- ✨ Add support for mixed-level nested keys with dot/blank handling
diff --git a/cmd/my-log/main.go b/cmd/my-log/main.go
index d09cd58..c7f2435 100644
--- a/cmd/my-log/main.go
+++ b/cmd/my-log/main.go
@@ -16,8 +16,8 @@ along with this program. If not, see .
*/
package main
-import "codeberg.org/danjones000/my-log/cli"
+import "codeberg.org/danjones000/my-log/internal/cmd"
func main() {
- cli.Execute()
+ cmd.Execute()
}
diff --git a/cli/config.go b/internal/cmd/config.go
similarity index 82%
rename from cli/config.go
rename to internal/cmd/config.go
index 59b2e12..1407796 100644
--- a/cli/config.go
+++ b/internal/cmd/config.go
@@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
-package cli
+package cmd
import (
"fmt"
@@ -25,9 +25,11 @@ import (
"github.com/spf13/cobra"
)
-var ConfigCmd = &cobra.Command{
- Use: "config",
- Short: "Save default config to file",
+// configCmd represents the config command
+var configCmd = &cobra.Command{
+ Use: "config",
+ Short: "Save default config to file",
+ //Long: ``,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) (err error) {
print, _ := cmd.Flags().GetBool("print")
@@ -60,8 +62,8 @@ var ConfigCmd = &cobra.Command{
}
func init() {
- RootCmd.AddCommand(ConfigCmd)
+ rootCmd.AddCommand(configCmd)
- ConfigCmd.Flags().BoolP("force", "f", false, "Force overwrite")
- ConfigCmd.Flags().BoolP("print", "p", false, "Print path only")
+ configCmd.Flags().BoolP("force", "f", false, "Force overwrite")
+ configCmd.Flags().BoolP("print", "p", false, "Print path only")
}
diff --git a/cli/drop.go b/internal/cmd/drop.go
similarity index 87%
rename from cli/drop.go
rename to internal/cmd/drop.go
index c319f93..2c246e6 100644
--- a/cli/drop.go
+++ b/internal/cmd/drop.go
@@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
-package cli
+package cmd
import (
"encoding/json"
@@ -34,8 +34,8 @@ var fields map[string]string
var j Json
var outJson bool
-// DropCmd represents the drop command
-var DropCmd = &cobra.Command{
+// dropCmd represents the drop command
+var dropCmd = &cobra.Command{
Use: "drop log title",
Short: "Add a new log entry",
// Long: ``,
@@ -83,13 +83,13 @@ var DropCmd = &cobra.Command{
}
func init() {
- RootCmd.AddCommand(DropCmd)
+ rootCmd.AddCommand(dropCmd)
(&d).Set("now")
- DropCmd.Flags().VarP(&d, "date", "d", "Date for log entry")
- DropCmd.Flags().StringToStringVarP(&fields, "fields", "f", nil, "Fields you add to entry")
- DropCmd.Flags().VarP(&j, "json", "j", "Entire entry as json")
- DropCmd.Flags().BoolVarP(&outJson, "output_json", "o", false, "Output result as JSON")
+ dropCmd.Flags().VarP(&d, "date", "d", "Date for log entry")
+ dropCmd.Flags().StringToStringVarP(&fields, "fields", "f", nil, "Fields you add to entry")
+ dropCmd.Flags().VarP(&j, "json", "j", "Entire entry as json")
+ dropCmd.Flags().BoolVarP(&outJson, "output_json", "o", false, "Output result as JSON")
}
type Json struct {
diff --git a/cli/root.go b/internal/cmd/root.go
similarity index 53%
rename from cli/root.go
rename to internal/cmd/root.go
index ca24e61..44de5f0 100644
--- a/cli/root.go
+++ b/internal/cmd/root.go
@@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
-package cli
+package cmd
import (
"os"
@@ -23,19 +23,36 @@ import (
"github.com/spf13/cobra"
)
-var RootCmd = &cobra.Command{
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
Use: "my-log",
Short: "A brief description of your application",
+ //Long: ``,
+ // Uncomment the following line if your bare application
+ // has an action associated with it:
+ // Run: func(cmd *cobra.Command, args []string) { },
}
+// Execute adds all child commands to the root command and sets flags appropriately.
+// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
- err := RootCmd.Execute()
+ err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
- RootCmd.PersistentFlags().StringVarP(&config.ConfigPath, "config", "c", config.ConfigPath, "config file")
- RootCmd.PersistentFlags().StringToStringVarP(&config.Overrides, "config-value", "v", config.Overrides, "Override config values. Use dot syntax to specify key. E.g. -v output.stdout.config.format=json")
+ //cobra.OnInitialize(initConfig)
+
+ // Here you will define your flags and configuration settings.
+ // Cobra supports persistent flags, which, if defined here,
+ // will be global for your application.
+
+ rootCmd.PersistentFlags().StringVarP(&config.ConfigPath, "config", "c", config.ConfigPath, "config file")
+ rootCmd.PersistentFlags().StringToStringVarP(&config.Overrides, "config-value", "v", config.Overrides, "Override config values. Use dot syntax to specify key. E.g. -v output.stdout.config.format=json")
+
+ // Cobra also supports local flags, which will only run
+ // when this action is called directly.
+ // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}