mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-17 04:20:59 +01:00
initial try
This commit is contained in:
30
cmd/extra.go
30
cmd/extra.go
@@ -24,11 +24,13 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tlinden/anydb/app"
|
||||
"github.com/tlinden/anydb/cfg"
|
||||
"github.com/tlinden/anydb/output"
|
||||
"github.com/tlinden/anydb/rest"
|
||||
"github.com/tlinden/anydb/ui"
|
||||
)
|
||||
|
||||
func Export(conf *cfg.Config) *cobra.Command {
|
||||
@@ -324,3 +326,31 @@ func editContent(editor string, content string) (string, error) {
|
||||
|
||||
return newcontentstr, nil
|
||||
}
|
||||
|
||||
func Shell(conf *cfg.Config) *cobra.Command {
|
||||
var cmd = &cobra.Command{
|
||||
Use: "shell",
|
||||
Short: "shell",
|
||||
Long: `interactive ui`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// errors at this stage do not cause the usage to be shown
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
entries, err := conf.DB.List(&app.DbAttr{}, conf.Fulltext)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p := tea.NewProgram(ui.NewModel(conf, entries), tea.WithAltScreen())
|
||||
if _, err := p.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().BoolVarP(&conf.NoHumanize, "no-human", "N", false, "do not translate to human readable values")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ func Execute() {
|
||||
rootCmd.AddCommand(Man(&conf))
|
||||
rootCmd.AddCommand(Info(&conf))
|
||||
rootCmd.AddCommand(Edit(&conf))
|
||||
rootCmd.AddCommand(Shell(&conf))
|
||||
|
||||
err = rootCmd.Execute()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user