-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (51 loc) · 1.26 KB
/
main.go
File metadata and controls
60 lines (51 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Package main contains toolkit that may be needed.
//
// This tool has the following sub command so far.
// AddAccount, ShowAccount, CopyPassword
package main
import (
"flag"
"fmt"
"github.com/fuwalab/tools/command"
"github.com/fuwalab/tools/conf"
"github.com/fuwalab/tools/db"
"github.com/labstack/gommon/log"
_ "github.com/mattn/go-sqlite3"
)
func init() {
conf.SetEnv("local")
}
func main() {
flag.Parse()
args := flag.Args()
if len(args) == 0 {
fmt.Print(usage())
return
}
subCommands := map[string]func(args ...string){
"AddAccount": command.Add,
"ShowAccount": command.Show,
"CopyPassword": command.CopyPassword,
"String": command.String,
}
c := args[0]
if _, ok := subCommands[c]; ok {
db.NewRepo(db.Conn()).InitDB()
f := subCommands[c]
f(args...)
} else {
log.Info("subcommand ", args[0], " is not exist")
}
}
func usage() string {
return `Usage:
AddAccount: Add a new account information.
Run "AddAccount -h" for more detail.
ShowAccount: Show account/user name of a particular service.
Run "ShowAccount -h" for more detail.
CopyPassword: Copy password of the particular service to clipboard.
Run "CopyPassword -h" for more detail.
String: Show encrypted/decrypted string
Run "String -h" for more detail.
`
}