Add interactive mode for tea milestone create #310

Merged
6543 merged 4 commits from YakoYakoYokuYoku/tea:interactive-ms into master 2020-12-17 18:50:08 +00:00
Contributor

Fixes #245.

Fixes #245.
YakoYakoYokuYoku added 1 commit 2020-12-17 13:54:29 +00:00
Implement interactive milestone creation
Signed-off-by: Martin Reboredo <yakoyoku@gmail.com>
All checks were successful
continuous-integration/drone/pr Build is passing
52641083c9
noerw reviewed 2020-12-17 13:58:36 +00:00
Dismissed
@ -0,0 +18,4 @@
// title is required
if len(title) == 0 {
fmt.Printf("Title is required\n")
Member

return fmt.Errorf("Title is required")

`return fmt.Errorf("Title is required")`
YakoYakoYokuYoku marked this conversation as resolved
noerw changed title from Add interactive mode for `tea issue create` to Add interactive mode for `tea milestone create` 2020-12-17 13:58:50 +00:00
noerw added the
kind
feature
label 2020-12-17 13:58:57 +00:00
Member

Thanks ?
Do you plan to ask for the deadline as well? That would be great as it prepares for #303

Thanks ? Do you plan to ask for the deadline as well? That would be great as it prepares for #303
noerw added this to the v0.7.0 milestone 2020-12-17 14:03:58 +00:00
YakoYakoYokuYoku added 1 commit 2020-12-17 14:08:41 +00:00
Return fmt.Errorf when title is empty
All checks were successful
continuous-integration/drone/pr Build is passing
a0835d3a18
Author
Contributor

Do you plan to ask for the deadline as well? That would be great as it prepares for #303

Yeah, let's do that.

> Do you plan to ask for the deadline as well? That would be great as it prepares for #303 Yeah, let's do that.
Author
Contributor

@noerw May I ask you the date layout for the deadline (see time.Parse)?

@noerw May I ask you the date layout for the deadline (see [time.Parse](https://pkg.go.dev/time#Parse))?
Owner

by the way pleace "update branch" ...

by the way pleace "update branch" ...
6543 reviewed 2020-12-17 14:34:24 +00:00
Dismissed
@ -43,28 +42,22 @@ var CmdMilestonesCreate = cli.Command{
func runMilestonesCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
Owner

isn't ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) still needed?

isn't `ctx.Ensure(context.CtxRequirement{RemoteRepo: true})` still needed?
Owner

cc @noerw

cc @noerw
Member

It is.

It is.
YakoYakoYokuYoku marked this conversation as resolved
YakoYakoYokuYoku added 1 commit 2020-12-17 14:42:50 +00:00
Merge branch 'master' into interactive-ms
All checks were successful
continuous-integration/drone/pr Build is passing
a169550f62
Member

@YakoYakoYokuYoku Regarding time parsing: I'd do something similar to

var t time.Time
if deadline != "" {
	if t, err := time.ParseInLocation(time.RFC3339, deadline); err != nil {
		if t, err = time.ParseInLocation(time.UnixDate, deadline); err != nil {
			return err
		}
	}
}

edit: doe RFC3339 accept date only? If not, we should accept a date in RFC3339 structure, but with only the date..

@YakoYakoYokuYoku Regarding time parsing: I'd do something similar to ``` var t time.Time if deadline != "" { if t, err := time.ParseInLocation(time.RFC3339, deadline); err != nil { if t, err = time.ParseInLocation(time.UnixDate, deadline); err != nil { return err } } } ``` edit: doe RFC3339 accept date only? If not, we should accept a date in RFC3339 structure, but with only the date..
YakoYakoYokuYoku force-pushed interactive-ms from a169550f62 to 747fa1345f 2020-12-17 14:47:16 +00:00 Compare
Author
Contributor

doe RFC3339 accept date only? If not, we should accept a date in RFC3339 structure, but with only the date..

It seems that time.RFC3339 doesn't support an ISO 8601 date structure with only the date, but we could nest two time.Parses (one with time.RFC3339 and the other with "2006-01-02") or we could use dateparse.ParseAny.

edit: dateparse is also in go.mod.

> doe RFC3339 accept date only? If not, we should accept a date in RFC3339 structure, but with only the date.. It seems that `time.RFC3339` doesn't support an ISO 8601 date structure with only the date, but we could nest two `time.Parse`s (one with `time.RFC3339` and the other with `"2006-01-02"`) or we could use `dateparse.ParseAny`. edit: `dateparse` is also in `go.mod`.
Member

@YakoYakoYokuYoku Sounds good to me to have "2006-01-02" and RFC3339 as fallback. I'd avoid another dependency

Scratch that, we already have dateparse ? Lets go for dateparse.ParseLocal

~~@YakoYakoYokuYoku Sounds good to me to have "2006-01-02" and RFC3339 as fallback. I'd avoid another dependency~~ Scratch that, we already have dateparse ? Lets go for `dateparse.ParseLocal`
YakoYakoYokuYoku added 1 commit 2020-12-17 16:28:44 +00:00
Incorporate deadline functionality
All checks were successful
continuous-integration/drone/pr Build is passing
4416c6099a
Author
Contributor

Yeah I know that I'm using time.Parse here, but I would be thankful if the reviews point out other important things.

Yeah I know that I'm using `time.Parse` here, but I would be thankful if the reviews point out other important things.
noerw requested changes 2020-12-17 17:10:18 +00:00
Dismissed
@ -0,0 +16,4 @@
)
// CreateMilestone interactively creates a milestone
func CreateMilestone(login *config.Login, owner, repo string, deadline *time.Time, state gitea.StateType) error {
Member

No need for the deadline & state params: They will never be set anyway

No need for the deadline & state params: They will never be set anyway
Owner

didn't he add a flag for this?

didn't he add a flag for this?
Member

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

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
Owner

no interactive should only if no flags are pressent - how would you integrate tea into scripts if it would ask you the whole time ...

no interactive should only if no flags are pressent - how would you integrate tea into scripts if it would ask you the whole time ...
Owner
-func CreateMilestone(login *config.Login, owner, repo string, deadline *time.Time, state gitea.StateType) error {
+func CreateMilestone(login *config.Login, owner, repo string) error {
```diff -func CreateMilestone(login *config.Login, owner, repo string, deadline *time.Time, state gitea.StateType) error { +func CreateMilestone(login *config.Login, owner, repo string) error { ```
YakoYakoYokuYoku marked this conversation as resolved
@ -0,0 +39,4 @@
}
// deadline
promptI = &survey.Input{Message: "Milestone deadline [no due date]:"}
Member

I'd put the date parsing inside a survey.Validator similar to promptRepoSlug(). This lets users iterate on wrong inputs, instead of failing the entire command

I'd put the date parsing inside a `survey.Validator` similar to `promptRepoSlug()`. This lets users iterate on wrong inputs, instead of failing the entire command
Author
Contributor

Gotcha, thx for pointing that out ?

Gotcha, thx for pointing that out ?
YakoYakoYokuYoku marked this conversation as resolved
6543 requested changes 2020-12-17 18:06:15 +00:00
Dismissed
@ -64,2 +68,2 @@
if err != nil {
return err
if ctx.NumFlags() == 0 {
return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo, deadline, state)
Owner
-		return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo, deadline, state)
+		return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo)
```diff - return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo, deadline, state) + return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo) ```
YakoYakoYokuYoku marked this conversation as resolved
@ -0,0 +17,4 @@
// 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
Owner
-	var title, description, dueDate string
+	var title, description, dueDate string
+	var deadline *time.Time
```diff - var title, description, dueDate string + var title, description, dueDate string + var deadline *time.Time ```
YakoYakoYokuYoku marked this conversation as resolved
@ -0,0 +59,4 @@
title,
description,
deadline,
state)
Owner
-		state)
+		gitea.StateOpen)
```diff - state) + gitea.StateOpen) ```
YakoYakoYokuYoku marked this conversation as resolved
YakoYakoYokuYoku added 1 commit 2020-12-17 18:30:13 +00:00
Use dateparse and cleanup CreateMilestone task
All checks were successful
continuous-integration/drone/pr Build is passing
2be9a124f2
YakoYakoYokuYoku requested review from noerw 2020-12-17 18:34:36 +00:00
YakoYakoYokuYoku requested review from 6543 2020-12-17 18:34:37 +00:00
noerw approved these changes 2020-12-17 18:40:22 +00:00
Dismissed
6543 approved these changes 2020-12-17 18:48:12 +00:00
Dismissed
6543 merged commit 43e9943757 into master 2020-12-17 18:50:08 +00:00
Owner

@YakoYakoYokuYoku nice work 👍

@YakoYakoYokuYoku nice work :+1:
Author
Contributor

You welcome too ?

You welcome too ?
Sign in to join this conversation.
No description provided.