pull/1/head
vilmibm 2022-07-31 21:24:50 +00:00
parent 122af44a9e
commit 571c37b089
4 changed files with 61 additions and 2 deletions

View File

@ -3,15 +3,16 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"os" "os"
"path/filepath"
) )
const ( const (
submitOp = "submit" submitOp = "submit"
delOp = "del" delOp = "del"
updateOp = "update" updateOp = "update"
dbpath = "/town/var/commands.db"
) )
type ContribOptions struct { type ContribOptions struct {
@ -36,10 +37,50 @@ func runContrib(opts *ContribOptions) error {
} }
func submit(opts *ContribOptions) error { func submit(opts *ContribOptions) error {
// TODO run survey var cmdName string
var category string
var shortDescription string
var longDescription string
_, defaultName := filepath.Split(opts.ExecPath)
if err := survey.AskOne(&survey.Input{
Message: "New command's name:",
Default: defaultName}, &cmdName); err != nil {
return err
}
categories := []string{
"art",
"social",
"game",
"utility",
"misc",
}
var choice int
if err := survey.AskOne(&survey.Select{
Message: "what category should this command be filed under?",
Options: categories,
}, &choice); err != nil {
return err
}
category = categories[choice]
fmt.Printf("DBG %#v\n", category)
if err := survey.AskOne(&survey.Input{
Message: "What's a one line description of this command?",
}, &shortDescription); err != nil {
return err
}
if err := survey.AskOne(&survey.Editor{
Message: "Write a long description for this command. Try to include examples. If the short description is enough, you can just leave it blank though. Really it's whatever you want. I donno"}, &longDescription); err != nil {
return nil
}
// TODO create pending row // TODO create pending row
// TODO email me // TODO email me
// TODO print confirmation // TODO print confirmation
return nil return nil
} }

5
db/db.go 100644
View File

@ -0,0 +1,5 @@
package db
const Path = "/town/var/town.sqlite3"
// TODO

11
go.mod
View File

@ -8,3 +8,14 @@ require (
github.com/spf13/cobra v1.5.0 github.com/spf13/cobra v1.5.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-sqlite3 v1.14.14 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/text v0.3.6 // indirect
)

2
go.sum
View File

@ -35,6 +35,8 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw=
github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/microcosm-cc/bluemonday v1.0.17 h1:Z1a//hgsQ4yjC+8zEkV8IWySkXnsxmdSY642CTFQb5Y= github.com/microcosm-cc/bluemonday v1.0.17 h1:Z1a//hgsQ4yjC+8zEkV8IWySkXnsxmdSY642CTFQb5Y=