From ebc25651f0fc5d51acf8182565706d670edff596 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Sun, 15 Sep 2019 21:21:52 -0700 Subject: [PATCH] add filename handling --- build.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/build.go b/build.go index a828ae4..a78ded3 100644 --- a/build.go +++ b/build.go @@ -127,8 +127,13 @@ func testCleanup() error { return nil } -func GfmrunActionFunc(_ *cli.Context) error { - file, err := os.Open("README.md") +func GfmrunActionFunc(c *cli.Context) error { + filename := c.Args().Get(0) + if filename == "" { + filename = "README.md" + } + + file, err := os.Open(filename) if err != nil { return err } @@ -146,11 +151,16 @@ func GfmrunActionFunc(_ *cli.Context) error { return err } - return runCmd("gfmrun", "-c", fmt.Sprint(counter), "-s", "README.md") + return runCmd("gfmrun", "-c", fmt.Sprint(counter), "-s", filename) } -func TocActionFunc(_ *cli.Context) error { - err := runCmd("node_modules/.bin/markdown-toc", "-i", "README.md") +func TocActionFunc(c *cli.Context) error { + filename := c.Args().Get(0) + if filename == "" { + filename = "README.md" + } + + err := runCmd("node_modules/.bin/markdown-toc", "-i", filename) if err != nil { return err }