Skip to content

Commit

Permalink
Add more comprehensive help text.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyll committed Nov 1, 2019
1 parent c1e3914 commit 6271d52
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions statik.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,53 @@ const nameSourceFile = "statik.go"
var namePackage string

var (
flagSrc = flag.String("src", path.Join(".", "public"), "The path of the source directory.")
flagDest = flag.String("dest", ".", "The destination path of the generated package.")
flagNoMtime = flag.Bool("m", false, "Ignore modification times on files.")
flagNoCompress = flag.Bool("Z", false, "Do not use compression to shrink the files.")
flagForce = flag.Bool("f", false, "Overwrite destination file if it already exists.")
flagTags = flag.String("tags", "", "Write build constraint tags")
flagPkg = flag.String("p", "statik", "Name of the generated package")
flagPkgCmt = flag.String("c", "Package statik contains static assets.", "The package comment. An empty value disables this comment.\n")
flagInclude = flag.String("include", "*.*", "The patterns of files to be included (by comma separated).\n")
flagSrc = flag.String("src", path.Join(".", "public"), "")
flagDest = flag.String("dest", ".", "")
flagNoMtime = flag.Bool("m", false, "")
flagNoCompress = flag.Bool("Z", false, "")
flagForce = flag.Bool("f", false, "")
flagTags = flag.String("tags", "", "")
flagPkg = flag.String("p", "statik", "")
flagPkgCmt = flag.String("c", "", "")
flagInclude = flag.String("include", "*.*", "")
)

const helpText = `statik [options]
Options:
-src The source directory of the assets. "public" by default.
-dest The destination directory of the generated package. "." by default.
-f Override destination if it already exists, false by default.
-include Wildcard to filter files to include, "*.*" by default.
-m Ignore modification times on files, false by default.
-Z Do not use compression, false by default.
-p Name of the generated package, "statik" by default.
-tags Build tags for the generated package.
-c Godoc for the generated package.
-help Prints this text.
Examples:
Generates a statik package from ./assets directory. Overrides
if there is already an existing package.
$ statik -src=assets -f
Generates a statik package only with the ".js" files
from the ./public directory.
$ statik -include=*.js
`

// mtimeDate holds the arbitrary mtime that we assign to files when
// flagNoMtime is set.
var mtimeDate = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)

func main() {
flag.Usage = help
flag.Parse()

namePackage = *flagPkg
Expand Down Expand Up @@ -286,3 +317,8 @@ func exitWithError(err error) {
fmt.Println(err)
os.Exit(1)
}

func help() {
fmt.Println(helpText)
os.Exit(1)
}

0 comments on commit 6271d52

Please sign in to comment.