-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4049fe
commit 55659a5
Showing
13 changed files
with
50 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package cmd | ||
|
||
var ( | ||
NewApp = newApp | ||
VersionPrinter = versionPrinter | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ package cmd | |
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/janiltonmaciel/statiks/lib" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// CreateApp. | ||
func CreateApp(version, commit, date string) *cli.App { | ||
// Run cli. | ||
func Run(version, commit, date string) error { | ||
cli.AppHelpTemplate = appHelpTemplate | ||
cli.VersionPrinter = versionPrinter(commit, date) | ||
cli.HelpFlag = &cli.BoolFlag{ | ||
|
@@ -21,18 +22,23 @@ func CreateApp(version, commit, date string) *cli.App { | |
Usage: "print the version", | ||
} | ||
|
||
app := createCliApp( | ||
app := newApp( | ||
version, | ||
) | ||
return app | ||
return app.Run(os.Args) | ||
} | ||
|
||
func createCliApp(version string) *cli.App { | ||
func newApp(version string) *cli.App { | ||
app := cli.NewApp() | ||
app.Name = "statiks" | ||
app.Usage = "fast, zero-configuration, static HTTP filer server." | ||
app.UsageText = "statiks [options] <path>" | ||
app.Authors = []*cli.Author{{Name: "Janilton Maciel", Email: "[email protected]"}} | ||
app.Authors = []*cli.Author{ | ||
{ | ||
Name: "Janilton Maciel", | ||
Email: "[email protected]", | ||
}, | ||
} | ||
app.Version = version | ||
app.Flags = createFlags() | ||
app.Action = func(c *cli.Context) error { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,22 @@ import ( | |
) | ||
|
||
func (s *StatiksSuite) TestApp(c *check.C) { | ||
commit := "da3c509" | ||
date := "2020-09-03T14:45:36Z" | ||
version := "v0.1" | ||
app := cmd.CreateApp(version, commit, date) | ||
app := cmd.NewApp(version) | ||
|
||
c.Assert(app.Version, check.Equals, version) | ||
c.Assert(app.Authors[0].Name, check.Equals, "Janilton Maciel") | ||
c.Assert(app.Authors[0].Email, check.Equals, "[email protected]") | ||
} | ||
|
||
func (s *StatiksSuite) TestVersionPrinter(c *check.C) { | ||
version := "v0.1" | ||
app := cmd.NewApp(version) | ||
|
||
commit := "da3c509" | ||
date := "2020-09-03T14:45:36Z" | ||
version := "v0.1" | ||
app := cmd.CreateApp(version, commit, date) | ||
set := flag.NewFlagSet("test", 0) | ||
ctx := cli.NewContext(app, set, nil) | ||
cli.VersionPrinter(ctx) | ||
vp := cmd.VersionPrinter(commit, date) | ||
vp(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package lib | ||
|
||
var ( | ||
NoCacheHandler = noCacheHandler | ||
CacheHandler = cacheHandler | ||
DelayHandler = delayHandler | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters