mirror of
https://github.com/facundoolano/jorge.git
synced 2024-11-16 07:47:40 +01:00
main with subcommand outline
This commit is contained in:
parent
9dba108572
commit
16cbf1d10e
2 changed files with 66 additions and 0 deletions
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module github.com/facundoolano/blorg
|
||||
|
||||
go 1.22.0
|
63
main.go
Normal file
63
main.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// TODO consider using cobra or something else to make cli more declarative
|
||||
// and get a better ux out of the box
|
||||
func main() {
|
||||
|
||||
initCmd := flag.NewFlagSet("init", flag.ExitOnError)
|
||||
buildCmd := flag.NewFlagSet("build", flag.ExitOnError)
|
||||
newCmd := flag.NewFlagSet("new", flag.ExitOnError)
|
||||
serveCmd := flag.NewFlagSet("serve", flag.ExitOnError)
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
printAndExit()
|
||||
}
|
||||
|
||||
switch os.Args[1] {
|
||||
|
||||
case "init":
|
||||
initCmd.Parse(os.Args[2:])
|
||||
// get working directory
|
||||
// default to .
|
||||
// if not exist, create directory
|
||||
// copy over default files
|
||||
fmt.Println("not implemented yet")
|
||||
case "build":
|
||||
buildCmd.Parse(os.Args[2:])
|
||||
// delete target if exist
|
||||
// create target dir
|
||||
// walk through files in src dir
|
||||
// copy them over to target
|
||||
// (later render templates and org)
|
||||
// (later minify)
|
||||
fmt.Println("not implemented yet")
|
||||
case "new":
|
||||
newCmd.Parse(os.Args[2:])
|
||||
// prompt for title
|
||||
// slugify
|
||||
// fail if file already exist
|
||||
// create a new .org file with the slug
|
||||
// add front matter and org options
|
||||
fmt.Println("not implemented yet")
|
||||
case "serve":
|
||||
// build
|
||||
// serve target with file server
|
||||
// (later watch and live reload)
|
||||
serveCmd.Parse(os.Args[2:])
|
||||
fmt.Println("not implemented yet")
|
||||
default:
|
||||
printAndExit()
|
||||
}
|
||||
}
|
||||
|
||||
func printAndExit() {
|
||||
// TODO print usage
|
||||
fmt.Println("expected a subcommand")
|
||||
os.Exit(1)
|
||||
}
|
Loading…
Reference in a new issue