Skip to content

Commit 76b0c9f

Browse files
committed
Token support
1 parent a1fce77 commit 76b0c9f

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

build

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#/bin/bash
22

33
GOOS=linux GOARCH=amd64 GO111MODULE=auto go build -o ./bin/convertapi
4-
zip -q -j -m -9 bin/convertapi_lin.zip bin/convertapi
4+
tar -I 'gzip -9' --remove-files -cvf bin/convertapi_lin.tar.gz -C bin convertapi
55

66
GOOS=linux GOARCH=arm GO111MODULE=auto go build -o bin/convertapi
7-
zip -q -j -m -9 bin/convertapi_lin_arm.zip bin/convertapi
8-
9-
GOOS=windows GOARCH=amd64 GO111MODULE=auto go build -o bin/convertapi.exe
10-
zip -q -j -m -9 bin/convertapi_win.zip bin/convertapi.exe
7+
tar -I 'gzip -9' --remove-files -cvf bin/convertapi_lin_arm.tar.gz -C bin convertapi
118

129
GOOS=darwin GOARCH=amd64 GO111MODULE=auto go build -o bin/convertapi
13-
zip -q -j -m -9 bin/convertapi_mac.zip bin/convertapi
10+
tar -I 'gzip -9' --remove-files -cvf bin/convertapi_mac.tar.gz -C bin convertapi
11+
12+
GOOS=darwin GOARCH=arm64 GO111MODULE=auto go build -o bin/convertapi
13+
tar -I 'gzip -9' --remove-files -cvf bin/convertapi_mac_arm.tar.gz -C bin convertapi
14+
15+
GOOS=windows GOARCH=amd64 GO111MODULE=auto go build -o bin/convertapi.exe
16+
zip -q -j -m -9 bin/convertapi_win.zip bin/convertapi.exe

httpclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type transport struct {
1212
}
1313

1414
func (this *transport) RoundTrip(req *http.Request) (*http.Response, error) {
15-
agent := fmt.Sprintf("convertapi-cli%s/%d", strings.Title(runtime.GOOS), Version)
15+
agent := fmt.Sprintf("ConvertAPI-CLI/%d (%s)", Version, strings.Title(runtime.GOOS))
1616
req.Header.Add("User-Agent", agent)
1717
return this.RoundTripper.RoundTrip(req)
1818
}

main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os"
99
)
1010

11-
const Version = 2
11+
const Version = 3
1212
const Name = "convertapi"
1313
const HelpFlagName = "help"
1414

@@ -18,6 +18,8 @@ func main() {
1818
paramsF := flag.String("params", "", "conversion parameters, see full list of available parameters at https://www.convertapi.com . Allowed values: [ value | @<path> | @< | < | << ]. Usage example: --params=\"file:@/path/to/file.doc, pdftitle:My title\"")
1919
outF := flag.String("out", "url", "place where to output converted files. Allowed values: [ url | @<path> | stdout ]. Save to directory example: --out=\"@/path/to/dir\" ")
2020
secretF := flag.String("secret", "", "ConvertAPI user secret. Get your secret at https://www.convertapi.com/a")
21+
tokenF := flag.String("token", "", "ConvertAPI user token. Get your secret at https://www.convertapi.com/a/auth")
22+
apikeyF := flag.String("apikey", "", "ConvertAPI user apikey. Get your secret at https://www.convertapi.com/a/auth")
2123
verF := flag.Bool("version", false, "output version information and exit")
2224
helpF := flag.Bool(HelpFlagName, false, "display this help and exit")
2325
flag.Parse()
@@ -36,7 +38,12 @@ func main() {
3638
}
3739

3840
if *secretF == "" {
39-
printError(errors.New("ConvertAPI user secret is not set. Please set --secret parameter. Get your secret at https://www.convertapi.com/a"), 1)
41+
if *tokenF == "" {
42+
printError(errors.New("ConvertAPI user secret is not set. Please set --secret or --token parameter. Get your secret at https://www.convertapi.com/a"), 1)
43+
} else {
44+
config.Default.Token = *tokenF
45+
config.Default.ApiKey = *apikeyF
46+
}
4047
} else {
4148
config.Default.Secret = *secretF
4249
}

0 commit comments

Comments
 (0)