diff --git a/CHANGELOG.md b/CHANGELOG.md
index f44599a..c3b3e0f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# 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/internal/cmd/config.go b/cli/config.go
similarity index 82%
rename from internal/cmd/config.go
rename to cli/config.go
index 1407796..59b2e12 100644
--- a/internal/cmd/config.go
+++ b/cli/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 cmd
+package cli
import (
"fmt"
@@ -25,11 +25,9 @@ import (
"github.com/spf13/cobra"
)
-// configCmd represents the config command
-var configCmd = &cobra.Command{
- Use: "config",
- Short: "Save default config to file",
- //Long: ``,
+var ConfigCmd = &cobra.Command{
+ Use: "config",
+ Short: "Save default config to file",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) (err error) {
print, _ := cmd.Flags().GetBool("print")
@@ -62,8 +60,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/internal/cmd/drop.go b/cli/drop.go
similarity index 87%
rename from internal/cmd/drop.go
rename to cli/drop.go
index 2c246e6..c319f93 100644
--- a/internal/cmd/drop.go
+++ b/cli/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 cmd
+package cli
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/internal/cmd/root.go b/cli/root.go
similarity index 53%
rename from internal/cmd/root.go
rename to cli/root.go
index 44de5f0..ca24e61 100644
--- a/internal/cmd/root.go
+++ b/cli/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 cmd
+package cli
import (
"os"
@@ -23,36 +23,19 @@ import (
"github.com/spf13/cobra"
)
-// rootCmd represents the base command when called without any subcommands
-var rootCmd = &cobra.Command{
+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() {
- //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")
+ 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")
}
diff --git a/cmd/my-log/main.go b/cmd/my-log/main.go
index c7f2435..d09cd58 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/internal/cmd"
+import "codeberg.org/danjones000/my-log/cli"
func main() {
- cmd.Execute()
+ cli.Execute()
}