Skip to content

Commit

Permalink
further improvements while using huh
Browse files Browse the repository at this point in the history
  • Loading branch information
jzyinq committed Mar 29, 2024
1 parent 0847733 commit cc15456
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Replace [manifoldco/promptui](https://github.com/charmbracelet/huh) with [charmbracelet/huh](https://github.com/charmbracelet/huh) due to lack of maintainer
- code cleanup pass, simplified structs, improved messaging, aligned variable naming

## [0.5.4] - 2024-03-29
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ require (
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/bubbles v0.18.0 // indirect
github.com/charmbracelet/bubbletea v0.25.0 // indirect
github.com/charmbracelet/lipgloss v0.9.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/charmbracelet/lipgloss v0.10.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/gdamore/encoding v1.0.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ github.com/charmbracelet/huh/spinner v0.0.0-20240328185852-590ecabc34b9 h1:gC8Qv
github.com/charmbracelet/huh/spinner v0.0.0-20240328185852-590ecabc34b9/go.mod h1:nrBG0YEHaxdbqHXW1xvG1hPqkuac9Eg7RTMvogiXuz0=
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s=
github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro=
github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
10 changes: 3 additions & 7 deletions gojira/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var IssuesCommand = &cli.Command{
if err != nil {
return err
}
timeSpent, err := InputTimeSpentForm()
timeSpent, err := InputTimeSpentForm(issue)
if err != nil {
return err
}
Expand Down Expand Up @@ -131,10 +131,8 @@ var LogWorkCommand = &cli.Command{
if err != nil {
return err
}
fmt.Printf("%s %s\n", issue.Key, issue.Fields.Summary)
fmt.Printf("Status: %s\n", issue.Fields.Status.Name)
if timeSpent == "" {
timeSpent, err = InputTimeSpentForm()
timeSpent, err = InputTimeSpentForm(issue)
if err != nil {
return err
}
Expand Down Expand Up @@ -183,9 +181,7 @@ var GitOrIssueListAction = func(c *cli.Context) error {
if err != nil {
return err
}
fmt.Printf("Status: %s\nSummary: %s\n", issue.Fields.Status.Name, issue.Fields.Summary)
// log time or view issue
timeSpent, err := InputTimeSpentForm()
timeSpent, err := InputTimeSpentForm(issue)
if err != nil {
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion gojira/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func SelectIssueForm(issues []Issue) (Issue, error) {
huh.NewGroup(
huh.NewSelect[Issue]().
Title("Choose issue").
Description("Recently updated issues assigned to you:").
Options(formOptions...).
Value(&chosenIssue),
),
Expand All @@ -55,13 +56,14 @@ func SelectIssueForm(issues []Issue) (Issue, error) {
return chosenIssue, nil
}

func InputTimeSpentForm() (string, error) {
func InputTimeSpentForm(issue Issue) (string, error) {
timeSpent := ""

form := huh.NewForm(
huh.NewGroup(
huh.NewInput().
Title("Log time").
Description(fmt.Sprintf("%s %s", issue.Key, issue.Fields.Summary)).
Placeholder("1h / 1h30m / 30m").
Value(&timeSpent).
Validate(func(input string) error {
Expand Down

0 comments on commit cc15456

Please sign in to comment.