Last active
February 25, 2020 21:57
-
-
Save suntong/7eed1480ce3e7f508b4d728547696a33 to your computer and use it in GitHub Desktop.
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
// -*- go -*- | |
//////////////////////////////////////////////////////////////////////////// | |
// Program: picv | |
// Purpose: picture vault | |
//////////////////////////////////////////////////////////////////////////// | |
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/mkideal/cli" | |
) | |
//////////////////////////////////////////////////////////////////////////// | |
// picv | |
type rootT struct { | |
//cli.Helper | |
Glob string `cli:"G,glob" usage:"glob defines the image files matching pattern" dft:".*\\.jpg$$"` | |
Gap int `cli:"g,gap" usage:"Gap in days to be considered as different group/vault" dft:"5"` | |
Pod int `cli:"p,pod" usage:"Minimum number of picture to have before splitting to a different group/vault" dft:"15"` | |
Verbose cli.Counter `cli:"v,verbose" usage:"Verbose mode (Multiple -v options increase the verbosity.)"` | |
} | |
var root = &cli.Command{ | |
Name: "picv", | |
Desc: "picture vault", | |
Text: "Tool to deal with camera pictures and put them in vault", | |
Argv: func() interface{} { return new(rootT) }, | |
Fn: picv, | |
CanSubRoute: true, | |
} | |
func main() { | |
cli.SetUsageStyle(cli.ManualStyle) // up-down, for left-right, use NormalStyle | |
//NOTE: You can set any writer implements io.Writer | |
// default writer is os.Stdout | |
if err := cli.Root(root).Run(os.Args[1:]); err != nil { | |
fmt.Fprintln(os.Stderr, err) | |
} | |
fmt.Println("") | |
} | |
func picv(ctx *cli.Context) error { | |
ctx.JSON(ctx.RootArgv()) | |
ctx.JSON(ctx.Argv()) | |
fmt.Println() | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dft:".*\\.jpg$"
changed todft:".*\\.jpg$$"
.