forked from tildetown/town
properly seed rand. accept comments. fix u.Name
parent
4a2d31e5fd
commit
e668db7e15
|
@ -8,6 +8,7 @@ import (
|
|||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"git.tilde.town/tildetown/town/email"
|
||||
tuser "git.tilde.town/tildetown/town/user"
|
||||
|
@ -38,6 +39,7 @@ type contrib struct {
|
|||
Category string
|
||||
ShortDesc string
|
||||
LongDesc string
|
||||
Comments string
|
||||
}
|
||||
|
||||
func runContrib(opts *contribOpts) error {
|
||||
|
@ -69,10 +71,13 @@ func validExec(execPath string) error {
|
|||
}
|
||||
|
||||
func submit(opts *contribOpts) error {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
var cmdName string
|
||||
var category string
|
||||
var shortDesc string
|
||||
var longDesc string
|
||||
var comments string
|
||||
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
|
@ -128,6 +133,12 @@ func submit(opts *contribOpts) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := survey.AskOne(&survey.Multiline{
|
||||
Message: "any comments for the admins? this won't be public, it's just to give admins any additional context about this command.",
|
||||
}, &comments); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO be able to set a maintainer other than caller. this might only be if an admin.
|
||||
// TODO would be fun if it was a Select using a user list -- extract that from stats cmd
|
||||
|
||||
|
@ -138,8 +149,9 @@ func submit(opts *contribOpts) error {
|
|||
LongDesc: longDesc,
|
||||
ExecPath: opts.ExecPath,
|
||||
// for later validation against file owner
|
||||
Maintainer: u.Name,
|
||||
Maintainer: u.Username,
|
||||
MaintainerUID: u.Uid,
|
||||
Comments: comments,
|
||||
}
|
||||
|
||||
bs, err := yaml.Marshal(c)
|
||||
|
|
Loading…
Reference in New Issue