From ca5b5bafcd92a33c916a4bbd80edf94974fcd923 Mon Sep 17 00:00:00 2001 From: JonghunYu Date: Fri, 6 Feb 2026 14:30:25 +0900 Subject: [PATCH 1/4] Add issue #021: open command to launch markdown in default program Co-Authored-By: Claude Opus 4.6 --- .gitignore | 5 +-- .issues/.counter | 2 +- ...le-command-to-open-issue-markdown-in-de.md | 33 +++++++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md diff --git a/.gitignore b/.gitignore index 3b1d510..1591736 100644 --- a/.gitignore +++ b/.gitignore @@ -29,11 +29,8 @@ go.work.sum # env file .env -# Editor/IDE -# .idea/ -# .vscode/ - # Editor/IDE .claude/ test/ +.DS_Store diff --git a/.issues/.counter b/.issues/.counter index aabe6ec..2bd5a0a 100644 --- a/.issues/.counter +++ b/.issues/.counter @@ -1 +1 @@ -21 +22 diff --git a/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md b/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md new file mode 100644 index 0000000..5434c23 --- /dev/null +++ b/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md @@ -0,0 +1,33 @@ +--- +id: "021" +assignee: "" +labels: + - feature +created: 2026-02-06T14:27:24.912527+09:00 +updated: 2026-02-06T14:27:24.912527+09:00 +--- + +# Add open-file command to open issue markdown in default program + +## Description + +Add a new `gi open` command that opens an issue's markdown file using the system's default program associated with the `.md` extension. This allows users to quickly view or edit issues in their preferred markdown editor or viewer (e.g., Typora, VS Code, Obsidian). + +Usage: `gi open 001` + +## Requirements + +- Accept an issue ID as argument (e.g., `gi open 001`) +- Look up the issue file in `.issues/open/` and `.issues/closed/` +- Open the file using the OS default program for `.md` files: + - macOS: use `open` command + - Linux: use `xdg-open` command +- Show an error if the issue ID is not found + +## Success Criteria + +- [ ] `gi open ` opens the issue markdown in the default associated program +- [ ] Works on macOS (`open`) and Linux (`xdg-open`) +- [ ] Displays clear error when issue ID does not exist +- [ ] Unit tests for file lookup logic +- [ ] Update README file From ada671aa20ea3a7edfe4b6f4a9ecbd3535cebcdf Mon Sep 17 00:00:00 2001 From: JonghunYu Date: Fri, 6 Feb 2026 14:38:30 +0900 Subject: [PATCH 2/4] Add gi view command to open issues in default program (#021) Implements the view command that opens an issue's markdown file in the system's default program (open on macOS, xdg-open on Linux). Co-Authored-By: Claude Opus 4.6 --- ...le-command-to-open-issue-markdown-in-de.md | 10 ++-- README.md | 7 +++ cmd/view.go | 51 +++++++++++++++++++ cmd/view_test.go | 21 ++++++++ 4 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 cmd/view.go create mode 100644 cmd/view_test.go diff --git a/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md b/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md index 5434c23..377bda4 100644 --- a/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md +++ b/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md @@ -7,17 +7,17 @@ created: 2026-02-06T14:27:24.912527+09:00 updated: 2026-02-06T14:27:24.912527+09:00 --- -# Add open-file command to open issue markdown in default program +# Add view command to open issue markdown in default program ## Description -Add a new `gi open` command that opens an issue's markdown file using the system's default program associated with the `.md` extension. This allows users to quickly view or edit issues in their preferred markdown editor or viewer (e.g., Typora, VS Code, Obsidian). +Add a new `gi view` command that opens an issue's markdown file using the system's default program associated with the `.md` extension. This allows users to quickly view or edit issues in their preferred markdown editor or viewer (e.g., Typora, VS Code, Obsidian). -Usage: `gi open 001` +Usage: `gi view 001` ## Requirements -- Accept an issue ID as argument (e.g., `gi open 001`) +- Accept an issue ID as argument (e.g., `gi view 001`) - Look up the issue file in `.issues/open/` and `.issues/closed/` - Open the file using the OS default program for `.md` files: - macOS: use `open` command @@ -26,7 +26,7 @@ Usage: `gi open 001` ## Success Criteria -- [ ] `gi open ` opens the issue markdown in the default associated program +- [ ] `gi view ` opens the issue markdown in the default associated program - [ ] Works on macOS (`open`) and Linux (`xdg-open`) - [ ] Displays clear error when issue ID does not exist - [ ] Unit tests for file lookup logic diff --git a/README.md b/README.md index 777c842..472187e 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,13 @@ gi edit 001 # Opens the issue file in $EDITOR (defaults to vim) ``` +### View an issue in default program + +```bash +gi view 001 +# Opens the issue markdown file in the system's default program +``` + ### Search issues ```bash diff --git a/cmd/view.go b/cmd/view.go new file mode 100644 index 0000000..e0ac149 --- /dev/null +++ b/cmd/view.go @@ -0,0 +1,51 @@ +package cmd + +import ( + "fmt" + "os/exec" + "runtime" + + "github.com/Allra-Fintech/git-issue/pkg" + "github.com/spf13/cobra" +) + +var viewCmd = &cobra.Command{ + Use: "view ", + Short: "Open an issue in the default program", + Long: `Open an issue's markdown file in the system's default program (e.g., Typora, VS Code, Obsidian).`, + Args: cobra.ExactArgs(1), + RunE: runView, +} + +func init() { + rootCmd.AddCommand(viewCmd) +} + +func runView(cmd *cobra.Command, args []string) error { + issueID := args[0] + + // Find the issue file + path, _, err := pkg.FindIssueFile(issueID) + if err != nil { + return fmt.Errorf("failed to find issue: %w", err) + } + + // Determine the OS-appropriate open command + var opener string + switch runtime.GOOS { + case "darwin": + opener = "open" + case "linux": + opener = "xdg-open" + default: + return fmt.Errorf("unsupported platform: %s", runtime.GOOS) + } + + // Open the file in the default program (non-blocking) + if err := exec.Command(opener, path).Start(); err != nil { + return fmt.Errorf("failed to open file: %w", err) + } + + fmt.Printf("✓ Opened issue #%s in default program\n", issueID) + return nil +} diff --git a/cmd/view_test.go b/cmd/view_test.go new file mode 100644 index 0000000..7e25e51 --- /dev/null +++ b/cmd/view_test.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "testing" +) + +func TestViewMissingArgs(t *testing.T) { + cmd := viewCmd + err := cmd.Args(cmd, []string{}) + if err == nil { + t.Error("expected error for missing arguments") + } +} + +func TestViewNonExistentIssue(t *testing.T) { + // runView should fail when the issue doesn't exist + err := runView(viewCmd, []string{"999"}) + if err == nil { + t.Error("expected error for non-existent issue") + } +} From 67efb2d73dddaea2cf8eeb10ab9d44a17767a928 Mon Sep 17 00:00:00 2001 From: JonghunYu Date: Fri, 6 Feb 2026 14:40:03 +0900 Subject: [PATCH 3/4] Close issue #021 --- .../021-add-open-file-command-to-open-issue-markdown-in-de.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .issues/{open => closed}/021-add-open-file-command-to-open-issue-markdown-in-de.md (96%) diff --git a/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md b/.issues/closed/021-add-open-file-command-to-open-issue-markdown-in-de.md similarity index 96% rename from .issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md rename to .issues/closed/021-add-open-file-command-to-open-issue-markdown-in-de.md index 377bda4..1213ce3 100644 --- a/.issues/open/021-add-open-file-command-to-open-issue-markdown-in-de.md +++ b/.issues/closed/021-add-open-file-command-to-open-issue-markdown-in-de.md @@ -4,7 +4,7 @@ assignee: "" labels: - feature created: 2026-02-06T14:27:24.912527+09:00 -updated: 2026-02-06T14:27:24.912527+09:00 +updated: 2026-02-06T14:40:03.891202+09:00 --- # Add view command to open issue markdown in default program From 51d5114babadd67fe9bfedbc4b1744f4d14fecf1 Mon Sep 17 00:00:00 2001 From: JonghunYu Date: Fri, 6 Feb 2026 14:56:34 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20PR=20=EB=A6=AC=EB=B7=B0=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=B0=B1=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use fatih/color for success message in view command 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 --- cmd/view.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/view.go b/cmd/view.go index e0ac149..0ebc6fd 100644 --- a/cmd/view.go +++ b/cmd/view.go @@ -6,6 +6,7 @@ import ( "runtime" "github.com/Allra-Fintech/git-issue/pkg" + "github.com/fatih/color" "github.com/spf13/cobra" ) @@ -46,6 +47,6 @@ func runView(cmd *cobra.Command, args []string) error { return fmt.Errorf("failed to open file: %w", err) } - fmt.Printf("✓ Opened issue #%s in default program\n", issueID) + color.New(color.FgGreen).Printf("✓ Opened issue #%s in default program\n", issueID) return nil }