Permalink
Browse files

update help message

  • Loading branch information...
dtduc91 committed Mar 28, 2018
1 parent bd3f077 commit 7f4c5f38f69a76708f5130eda2e594cf47302c6d
Showing with 35 additions and 27 deletions.
  1. +17 −13 README.md
  2. +18 −14 main.go
View
@@ -42,30 +42,34 @@ These binaries are available for download.
https://github.com/kintone/cli-kintone/releases
## Usage
```bash
Usage:
cli-kintone.darwin.amd64 [OPTIONS]
Application Options:
-d= Domain name
-u= Login name
-p= Password
-d= Domain name (specify the FQDN)
-a= App ID (default: 0)
-u= User's log in name
-p= User's password
-t= API token
-g= Guest Space ID (default: 0)
-o= Output format. Specify either 'json' or 'csv' (default: csv)
-e= Character encoding. Specify one of the following -> 'utf-8'(default), 'utf-16', 'utf-16be-with-signature', 'utf-16le-with-signature', 'sjis' or
'euc-jp' (default: utf-8)
-U= Basic authentication user name
-P= Basic authentication password
-t= API token
-o= Output format: 'json' or 'csv' (default: csv)
-q= Query string
-a= App ID (default: 0)
-c= Field names (comma separated)
-c= Fields to export (comma separated). Specify the field code name
-f= Input file path
-D Delete all records before inserting
-e= Character encoding: 'utf-8', 'utf-16', 'utf-16be-with-signature', 'utf-16le-with-signature', 'sjis' or 'euc-jp' (default: utf-8)
-g= Guest Space ID (default: 0)
-b= Attachment file directory
-l= The position index of data in the input file (default: 1)
--import Force import
--export Force export
-D Delete records before insert. You can specify the deleting record condition by option "-q"
-l= Position index of data in the input file (default: 1)
--import Import data from stdin. If "-f" is also specified, data is imported from the file instead
--export Export kintone data to stdout
Help Options:
-h, --help Show this help message
```
## Examples
### Export all columns from an app
View
32 main.go
@@ -29,24 +29,24 @@ const EXPORT_ROW_LIMIT = 500
// Configure of this package
type Configure struct {
Domain string `short:"d" default:"" description:"Domain name"`
Login string `short:"u" default:"" description:"Login name"`
Password string `short:"p" default:"" description:"Password"`
Domain string `short:"d" default:"" description:"Domain name (specify the FQDN)"`
AppID uint64 `short:"a" default:"0" description:"App ID"`
Login string `short:"u" default:"" description:"User's log in name"`
Password string `short:"p" default:"" description:"User's password"`
APIToken string `short:"t" default:"" description:"API token"`
GuestSpaceID uint64 `short:"g" default:"0" description:"Guest Space ID"`
Format string `short:"o" default:"csv" description:"Output format. Specify either 'json' or 'csv'"`
Encoding string `short:"e" default:"utf-8" description:"Character encoding. Specify one of the following -> 'utf-8'(default), 'utf-16', 'utf-16be-with-signature', 'utf-16le-with-signature', 'sjis' or 'euc-jp'"`
BasicAuthUser string `short:"U" default:"" description:"Basic authentication user name"`
BasicAuthPassword string `short:"P" default:"" description:"Basic authentication password"`
APIToken string `short:"t" default:"" description:"API token"`
Format string `short:"o" default:"csv" description:"Output format: 'json' or 'csv'"`
Query string `short:"q" default:"" description:"Query string"`
AppID uint64 `short:"a" default:"0" description:"App ID"`
Fields []string `short:"c" description:"Field names (comma separated)"`
Fields []string `short:"c" description:"Fields to export (comma separated). Specify the field code name"`
FilePath string `short:"f" default:"" description:"Input file path"`
DeleteAll bool `short:"D" description:"Delete all records before inserting"`
Encoding string `short:"e" default:"utf-8" description:"Character encoding: 'utf-8', 'utf-16', 'utf-16be-with-signature', 'utf-16le-with-signature', 'sjis' or 'euc-jp'"`
GuestSpaceID uint64 `short:"g" default:"0" description:"Guest Space ID"`
FileDir string `short:"b" default:"" description:"Attachment file directory"`
Line uint64 `short:"l" default:"1" description:"The position index of data in the input file"`
IsImport bool `long:"import" description:"Force import"`
IsExport bool `long:"export" description:"Force export"`
DeleteAll bool `short:"D" description:"Delete records before insert. You can specify the deleting record condition by option \"-q\""`
Line uint64 `short:"l" default:"1" description:"Position index of data in the input file"`
IsImport bool `long:"import" description:"Import data from stdin. If \"-f\" is also specified, data is imported from the file instead"`
IsExport bool `long:"export" description:"Export kintone data to stdout"`
}
var config Configure
@@ -153,9 +153,13 @@ func main() {
_, err = flags.ParseArgs(&config, os.Args[1:])
if err != nil {
if os.Args[1] != "-h" && os.Args[1] != "--help" {
fileExecute := os.Args[0]
fmt.Printf("\nTry '%s --help' for more information.\n", fileExecute)
}
os.Exit(1)
}
if config.AppID == 0 || (config.APIToken == "" && (config.Domain == "" || config.Login == "")) {
if len(os.Args) == 0 || config.AppID == 0 || (config.APIToken == "" && (config.Domain == "" || config.Login == "")) {
helpArg := []string{"-h"}
flags.ParseArgs(&config, helpArg)
os.Exit(1)

0 comments on commit 7f4c5f3

Please sign in to comment.