CLI/TUI for drafting, repeating, and publishing daily standup updates as GitHub issues
github go cli golang management project tui daily
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 87 lines 1.7 kB view raw
1package cmd 2 3import ( 4 "context" 5 "errors" 6 "fmt" 7 8 "github.com/spf13/cobra" 9 "github.com/vieitesss/pad/internal/daily" 10 "github.com/vieitesss/pad/internal/tui" 11) 12 13func newCreateCmd() *cobra.Command { 14 var date string 15 var dryRun bool 16 17 cmd := &cobra.Command{ 18 Use: "create", 19 Short: "Open the daily update editor and create the GitHub issue", 20 RunE: func(cmd *cobra.Command, _ []string) error { 21 env, err := loadEnv() 22 if err != nil { 23 return err 24 } 25 26 resolvedDate, err := resolveDate(date) 27 if err != nil { 28 return err 29 } 30 31 ctx := context.Background() 32 template, err := loadIssueTemplate(ctx, env) 33 if err != nil { 34 return err 35 } 36 37 if !dryRun { 38 if err := ensureCanCreateForDate(ctx, env, resolvedDate); err != nil { 39 return err 40 } 41 } 42 43 entry := daily.New(resolvedDate, template) 44 45 if dryRun { 46 entry, err = tui.Edit(entry) 47 } else { 48 entry, err = tui.EditForCreate(entry) 49 } 50 if err != nil { 51 if errors.Is(err, tui.ErrCanceled) { 52 fmt.Fprintln(cmd.OutOrStdout(), "edit canceled") 53 return nil 54 } 55 56 return err 57 } 58 59 if dryRun { 60 title, err := entry.Title() 61 if err != nil { 62 return err 63 } 64 65 fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n%s\n", title, entry.Body()) 66 return nil 67 } 68 69 if err := entry.ValidateForCreate(); err != nil { 70 return err 71 } 72 73 issue, err := createIssueFromEntry(ctx, env, entry) 74 if err != nil { 75 return err 76 } 77 78 fmt.Fprintln(cmd.OutOrStdout(), issue.URL) 79 return nil 80 }, 81 } 82 83 cmd.Flags().StringVar(&date, "date", "", "Entry date in YYYY-MM-DD format") 84 cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Open the editor and print the title/body without creating a GitHub issue") 85 86 return cmd 87}