initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
addCmd = &cobra.Command{
|
||||
Short: "Add note to depository",
|
||||
Use: "add [note]",
|
||||
Run: addNote,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(addCmd)
|
||||
}
|
||||
|
||||
func addNote(cmd *cobra.Command, args []string) {
|
||||
// open new note in $EDITOR
|
||||
|
||||
fmt.Println(args)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.jnss.me/joakim/jadedepo/internal/engine"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
rootCmd = &cobra.Command{
|
||||
Short: "Jade CLI is a note-manager and orchestrator.",
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
cfgPath string
|
||||
depoPath string
|
||||
)
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(func() {
|
||||
if _, err := engine.Init(cfgPath, depoPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error initializing configuration: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&cfgPath, "config", "", "Configuration path. Default $HOME/.config/jade")
|
||||
rootCmd.PersistentFlags().StringVar(&depoPath, "depo", "", "Depository path. Default $HOME/jade-depository")
|
||||
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
Reference in New Issue
Block a user