Skip to content

Instantly share code, notes, and snippets.

@suntong
Last active February 25, 2020 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suntong/7eed1480ce3e7f508b4d728547696a33 to your computer and use it in GitHub Desktop.
Save suntong/7eed1480ce3e7f508b4d728547696a33 to your computer and use it in GitHub Desktop.
// -*- 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
}
@mkideal
Copy link

mkideal commented Aug 11, 2018

dft:".*\\.jpg$" should be changed to dft:".*\\.jpg$$" because $ is a special character

@suntong
Copy link
Author

suntong commented Feb 25, 2020

dft:".*\\.jpg$" changed to dft:".*\\.jpg$$".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment