mirror of
https://github.com/boolean-maybe/tiki
synced 2026-04-21 13:37:20 +00:00
add git demo
This commit is contained in:
parent
7cd8922f2f
commit
e8fe742d01
2 changed files with 44 additions and 1 deletions
|
|
@ -101,6 +101,14 @@ All vim-like pager commands are supported in addition to:
|
|||
|
||||
<img src=".doc/doki/doc/kanban.gif" alt="Kanban demo" width="800">
|
||||
|
||||
to try with a demo project just run:
|
||||
|
||||
```
|
||||
cd /tmp && tiki demo
|
||||
```
|
||||
|
||||
this will clone and show a demo project. Once done you can try your own:
|
||||
|
||||
`cd` into your **git** repo and run `tiki init` to initialize.
|
||||
Move your tiki around the board with `Shift ←/Shift →`.
|
||||
Make sure to press `?` for help.
|
||||
|
|
|
|||
37
main.go
37
main.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/boolean-maybe/tiki/config"
|
||||
"github.com/boolean-maybe/tiki/internal/app"
|
||||
|
|
@ -39,6 +40,14 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
// Handle demo command — must run before InitPaths so that os.Chdir takes effect
|
||||
if len(os.Args) > 1 && os.Args[1] == "demo" {
|
||||
if err := runDemo(); err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, "error:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize paths early - this must succeed for the application to function
|
||||
if err := config.InitPaths(); err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, "error:", err)
|
||||
|
|
@ -61,7 +70,7 @@ func main() {
|
|||
|
||||
// Handle viewer mode (standalone markdown viewer)
|
||||
// "init" is reserved to prevent treating it as a markdown file
|
||||
viewerInput, runViewer, err := viewer.ParseViewerInput(os.Args[1:], map[string]struct{}{"init": {}})
|
||||
viewerInput, runViewer, err := viewer.ParseViewerInput(os.Args[1:], map[string]struct{}{"init": {}, "demo": {}})
|
||||
if err != nil {
|
||||
if errors.Is(err, viewer.ErrMultipleInputs) {
|
||||
_, _ = fmt.Fprintln(os.Stderr, "error:", err)
|
||||
|
|
@ -131,6 +140,31 @@ func runSysInfo() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
const demoRepoURL = "https://github.com/boolean-maybe/tiki-demo.git"
|
||||
const demoDirName = "tiki-demo"
|
||||
|
||||
// runDemo clones the demo repository if needed and changes into it.
|
||||
// Must be called before config.InitPaths() so the PathManager captures the demo dir as project root.
|
||||
func runDemo() error {
|
||||
info, err := os.Stat(demoDirName)
|
||||
if err == nil && info.IsDir() {
|
||||
fmt.Printf("using existing %s directory\n", demoDirName)
|
||||
} else {
|
||||
fmt.Printf("cloning demo project into %s...\n", demoDirName)
|
||||
//nolint:gosec // G204: fixed URL, not user-controlled
|
||||
cmd := exec.Command("git", "clone", demoRepoURL)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("git clone failed: %w", err)
|
||||
}
|
||||
}
|
||||
if err := os.Chdir(demoDirName); err != nil {
|
||||
return fmt.Errorf("change to demo directory: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// printUsage prints usage information when tiki is run in an uninitialized repo.
|
||||
func printUsage() {
|
||||
fmt.Print(`tiki - Terminal-based task and documentation management
|
||||
|
|
@ -138,6 +172,7 @@ func printUsage() {
|
|||
Usage:
|
||||
tiki Launch TUI in initialized repo
|
||||
tiki init Initialize project in current git repo
|
||||
tiki demo Clone demo project and launch TUI
|
||||
tiki file.md/URL View markdown file or image
|
||||
echo "Title" | tiki Create task from piped input
|
||||
tiki sysinfo Display system information
|
||||
|
|
|
|||
Loading…
Reference in a new issue