Compare commits

...

4 commits

Author SHA1 Message Date
572d868c24 🔀 Merge tag 'v0.1.0' into develop
🔖 New version which allows extendability
2026-02-28 16:51:11 -06:00
5307749e89 🔀 Merge branch 'rel/0.1.0' into stable 2026-02-28 16:49:51 -06:00
9a6806c156 📝 Update CHANGELOG for v0.1.0 release 2026-02-28 16:49:31 -06:00
8c23375208 Move CLI commands to cli/ package for extensibility
- Rename internal/cmd/ to cli/
- Export commands: RootCmd, DropCmd, ConfigCmd
- Enable custom app creation by importing cli package
2026-02-28 16:45:57 -06:00
5 changed files with 27 additions and 41 deletions

View file

@ -1,5 +1,10 @@
# Changelog # 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 ## [0.0.11] - 2026-02-13
- ✨ Add support for mixed-level nested keys with dot/blank handling - ✨ Add support for mixed-level nested keys with dot/blank handling

View file

@ -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 You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package cmd package cli
import ( import (
"fmt" "fmt"
@ -25,11 +25,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// configCmd represents the config command var ConfigCmd = &cobra.Command{
var configCmd = &cobra.Command{
Use: "config", Use: "config",
Short: "Save default config to file", Short: "Save default config to file",
//Long: ``,
SilenceUsage: true, SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) (err error) { RunE: func(cmd *cobra.Command, args []string) (err error) {
print, _ := cmd.Flags().GetBool("print") print, _ := cmd.Flags().GetBool("print")
@ -62,8 +60,8 @@ var configCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(configCmd) RootCmd.AddCommand(ConfigCmd)
configCmd.Flags().BoolP("force", "f", false, "Force overwrite") ConfigCmd.Flags().BoolP("force", "f", false, "Force overwrite")
configCmd.Flags().BoolP("print", "p", false, "Print path only") ConfigCmd.Flags().BoolP("print", "p", false, "Print path only")
} }

View file

@ -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 You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package cmd package cli
import ( import (
"encoding/json" "encoding/json"
@ -34,8 +34,8 @@ var fields map[string]string
var j Json var j Json
var outJson bool var outJson bool
// dropCmd represents the drop command // DropCmd represents the drop command
var dropCmd = &cobra.Command{ var DropCmd = &cobra.Command{
Use: "drop log title", Use: "drop log title",
Short: "Add a new log entry", Short: "Add a new log entry",
// Long: ``, // Long: ``,
@ -83,13 +83,13 @@ var dropCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(dropCmd) RootCmd.AddCommand(DropCmd)
(&d).Set("now") (&d).Set("now")
dropCmd.Flags().VarP(&d, "date", "d", "Date for log entry") DropCmd.Flags().VarP(&d, "date", "d", "Date for log entry")
dropCmd.Flags().StringToStringVarP(&fields, "fields", "f", nil, "Fields you add to 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().VarP(&j, "json", "j", "Entire entry as json")
dropCmd.Flags().BoolVarP(&outJson, "output_json", "o", false, "Output result as JSON") DropCmd.Flags().BoolVarP(&outJson, "output_json", "o", false, "Output result as JSON")
} }
type Json struct { type Json struct {

View file

@ -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 You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package cmd package cli
import ( import (
"os" "os"
@ -23,36 +23,19 @@ import (
"github.com/spf13/cobra" "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", Use: "my-log",
Short: "A brief description of your application", 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() { func Execute() {
err := rootCmd.Execute() err := RootCmd.Execute()
if err != nil { if err != nil {
os.Exit(1) os.Exit(1)
} }
} }
func init() { func init() {
//cobra.OnInitialize(initConfig) 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")
// 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")
} }

View file

@ -16,8 +16,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package main package main
import "codeberg.org/danjones000/my-log/internal/cmd" import "codeberg.org/danjones000/my-log/cli"
func main() { func main() {
cmd.Execute() cli.Execute()
} }