Add interactive mode for `tea milestone create` #310
Merged
6543
merged 4 commits from YakoYakoYokuYoku/tea:interactive-ms
into master
2 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'YakoYakoYokuYoku/tea:interactive-ms'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Fixes #245.
// title is required
if len(title) == 0 {
fmt.Printf("Title is required\n")
return fmt.Errorf("Title is required")
Add interactive mode for `tea issue create`to Add interactive mode for `tea milestone create` 2 years agoThanks 👍
Do you plan to ask for the deadline as well? That would be great as it prepares for #303
Yeah, let's do that.
@noerw May I ask you the date layout for the deadline (see time.Parse)?
by the way pleace "update branch" ...
func runMilestonesCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
isn't
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
still needed?cc @noerw
It is.
@YakoYakoYokuYoku Regarding time parsing: I'd do something similar to
edit: doe RFC3339 accept date only? If not, we should accept a date in RFC3339 structure, but with only the date..
a169550f62
to747fa1345f
2 years agoIt seems that
time.RFC3339
doesn't support an ISO 8601 date structure with only the date, but we could nest twotime.Parse
s (one withtime.RFC3339
and the other with"2006-01-02"
) or we could usedateparse.ParseAny
.edit:
dateparse
is also ingo.mod
.@YakoYakoYokuYoku Sounds good to me to have "2006-01-02" and RFC3339 as fallback. I'd avoid another dependencyScratch that, we already have dateparse 🙃 Lets go for
dateparse.ParseLocal
Yeah I know that I'm using
time.Parse
here, but I would be thankful if the reviews point out other important things.)
// CreateMilestone interactively creates a milestone
func CreateMilestone(login *config.Login, owner, repo string, deadline *time.Time, state gitea.StateType) error {
No need for the deadline & state params: They will never be set anyway
didn't he add a flag for this?
Yeah, but interactive mode won't be enabled if there is a flag set..
We could ofcourse change the condition to go into interactive mode, if not all mandatory flags are provided, but idk if that's better
no interactive should only if no flags are pressent - how would you integrate tea into scripts if it would ask you the whole time ...
}
// deadline
promptI = &survey.Input{Message: "Milestone deadline [no due date]:"}
I'd put the date parsing inside a
survey.Validator
similar topromptRepoSlug()
. This lets users iterate on wrong inputs, instead of failing the entire commandGotcha, thx for pointing that out 👍
if err != nil {
return err
if ctx.NumFlags() == 0 {
return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo, deadline, state)
// CreateMilestone interactively creates a milestone
func CreateMilestone(login *config.Login, owner, repo string, deadline *time.Time, state gitea.StateType) error {
var title, description, dueDate string
title,
description,
deadline,
state)
43e9943757
into master 2 years ago@YakoYakoYokuYoku nice work 👍
You welcome too 👏
43e9943757
.