dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit b83e730af80d40ad79c0212a12a67b35adfcdf61 (tree)
parent 4a5607f659793138e75bb0e9c470e0804ea684c1
Author: Motiejus Jakštys <desired.mta@gmail.com>
Date:   Thu,  4 Jun 2020 19:25:12 +0300

beginnings of joplin2site

Diffstat:
Asrc/joplin2site/go.mod | 5+++++
Asrc/joplin2site/go.sum | 2++
Asrc/joplin2site/main.go | 20++++++++++++++++++++
Asrc/joplin2site/run.go | 34++++++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/src/joplin2site/go.mod b/src/joplin2site/go.mod @@ -0,0 +1,5 @@ +module github.com/motiejus/dotfiles/joplin2site + +go 1.13 + +require github.com/jessevdk/go-flags v1.4.0 diff --git a/src/joplin2site/go.sum b/src/joplin2site/go.sum @@ -0,0 +1,2 @@ +github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= diff --git a/src/joplin2site/main.go b/src/joplin2site/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + a := &app{ + stdin: os.Stdin, + stdout: os.Stdout, + stderr: os.Stderr, + } + + if err := a.run(); err != nil { + fmt.Printf("ERROR: %v\n", err.Error()) + os.Exit(1) + } + os.Exit(0) +} diff --git a/src/joplin2site/run.go b/src/joplin2site/run.go @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + "io" + + goflags "github.com/jessevdk/go-flags" +) + +type flags struct { + PositionalArgs struct { + Dir goflags.Filename `long:"dir" description:"Directory with Joplin notes"` + } `positional-args:"yes" required:"yes"` +} + +type app struct { + stdin io.Reader + stdout io.Writer + stderr io.Writer +} + +func (a *app) run() error { + var opts flags + args, err := goflags.Parse(&opts) + if err != nil { + return err + } + if len(args) != 0 { + return fmt.Errorf("Got unexpected arguments: %q", args) + } + fmt.Printf("opts: %+v\n", opts) + + return nil +}