Skip to content

Commit 44f5e12

Browse files
author
rogerzr
committed
Merged develop into master
2 parents 08f1a01 + 6fb8fc7 commit 44f5e12

File tree

4 files changed

+271
-48
lines changed

4 files changed

+271
-48
lines changed

Readme.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,45 @@
22
[Nexus](https://github.com/jaracil/nexus/) command line tool. Wrapper of the golang [Nexus client](https://github.com/jaracil/nxcli)
33

44
## Install
5-
go get github.com/nayarsystems/nxctl
5+
go get github.com/nayarsystems/nxctl
6+
7+
## Config file
8+
9+
The config is read using [Viper](https://github.com/spf13/viper), so it supports JSON, TOML, YAML, HCL, or Java properties formats, from any of these paths:
10+
11+
* ./
12+
* $HOME/.nxctl/
13+
* $HOME/.config/nxctl/
14+
* $HOME/.local/config/nxctl/
15+
* /etc/nxctl/
16+
* %APPDATA%/nxctl/
17+
18+
--
19+
20+
$ cat /home/user/.config/nxctl/default.yml
21+
user: defaultuser
22+
password: secretpass
23+
server: wss://nexus.local
24+
timeout: 120
25+
26+
$ cat /home/user/.config/nxctl/production.json
27+
{
28+
"user" : "root"
29+
"password" : "%%verysecretpass%%",
30+
"server" : "wss://nexus.remote.com",
31+
}
32+
33+
34+
Config files can be selected by passing the -c flag, using the filename (without extension):
35+
36+
$ ./nxctl shell
37+
2016/08/12 08:21:08 Connected to wss://nexus.local
38+
2016/08/12 08:21:47 Logged as defaultuser
39+
...
40+
41+
$ ./nxctl -c production shell
42+
2016/08/12 08:21:08 Connected to wss://nexus.remote.com
43+
2016/08/12 08:21:47 Logged as root
44+
...
45+
46+

cross.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
GOOS=linux GOARCH=amd64 go build -o nxctl.linux.amd64
6+
GOOS=linux GOARCH=386 go build -o nxctl.linux.386
7+
8+
GOOS=darwin GOARCH=amd64 go build -o nxctl.darwin.amd64
9+
GOOS=darwin GOARCH=386 go build -o nxctl.darwin.386
10+
11+
GOOS=windows GOARCH=amd64 go build -o nxctl.windows.amd64.exe
12+
GOOS=windows GOARCH=386 go build -o nxctl.windows.386.exe
13+
14+
GOARCH=arm go build -o nxctl.arm

interface.go

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ package main
22

33
import "github.com/nayarsystems/kingpin"
44

5+
const (
6+
DEFAULT_USER = "test"
7+
DEFAULT_PASS = "test"
8+
DEFAULT_SERVER = "127.0.0.1:1717"
9+
DEFAULT_TIMEOUT = 60
10+
)
11+
512
var (
6-
app = kingpin.New("cli", "Nexus command line interface")
7-
serverIP = app.Flag("server", "Server address.").Default("127.0.0.1:1717").Short('s').String()
8-
timeout = app.Flag("timeout", "Execution timeout").Default("60").Short('t').Int()
9-
user = app.Flag("user", "Nexus username").Short('u').Default("test").String()
10-
pass = app.Flag("pass", "Nexus password").Default("test").Short('p').String()
13+
app = kingpin.New("cli", "Nexus command line interface")
14+
serverIP = app.Flag("server", "Server address.").Short('s').String()
15+
timeout = app.Flag("timeout", "Execution timeout").Short('t').Int()
16+
user = app.Flag("user", "Nexus username").Short('u').String()
17+
pass = app.Flag("pass", "Nexus password").Short('p').String()
18+
config = app.Flag("config", "Config filename").Short('c').String()
19+
ignoreapi = app.Flag("ignoreapi", "Ignore API version check").Bool()
1120

1221
///
1322

@@ -25,6 +34,10 @@ var (
2534
pushMethod = push.Arg("method", "Method to call").Required().String()
2635
pushParams = push.Arg("params", "parameters").StringMap()
2736

37+
pushJ = app.Command("pushj", "Execute a task.push rpc call on Nexus. Params is a json dict like: { 'param': value }")
38+
pushJMethod = pushJ.Arg("method", "Method to call").Required().String()
39+
pushJParams = pushJ.Arg("json {param:value,...}", "{'param': 3, 'other': {'val': true}}").Required().String()
40+
2841
pull = app.Command("pull", "Execute a task.pull rpc call on Nexus")
2942
pullMethod = pull.Arg("prefix", "Method to call").Required().String()
3043

@@ -69,6 +82,10 @@ var (
6982
userReload = userCmd.Command("reload", "Reloads users on a prefix")
7083
userReloadPrefix = userReload.Arg("prefix", "prefix").Required().String()
7184

85+
userMaxSessions = userCmd.Command("max-sessions", "Sets the maximum number of sessions for an user")
86+
userMaxSessionsUser = userMaxSessions.Arg("username", "username").Required().String()
87+
userMaxSessionsN = userMaxSessions.Arg("max", "max").Required().Int()
88+
7289
///
7390

7491
sessionsCmd = app.Command("sessions", "Show sessions info")
@@ -121,8 +138,29 @@ var (
121138
templateDelUser = templateDel.Arg("user", "user").Required().String()
122139
templateDelTemplate = templateDel.Arg("template", "template").Required().String()
123140

124-
templateList = templateCmd.Command("list", "List the templates from the user")
125-
templateListUser = templateList.Arg("user", "user").Required().String()
141+
//
142+
143+
whitelistCmd = app.Command("whitelist", "Whitelist management")
144+
145+
whitelistAdd = whitelistCmd.Command("add", "Whitelist an address for the user")
146+
whitelistAddUser = whitelistAdd.Arg("user", "user").Required().String()
147+
whitelistAddIP = whitelistAdd.Arg("ip", "ip regex").Required().String()
148+
149+
whitelistDel = whitelistCmd.Command("del", "Removes a whitelisted address from the user")
150+
whitelistDelUser = whitelistDel.Arg("user", "user").Required().String()
151+
whitelistDelIP = whitelistDel.Arg("ip", "ip regex").Required().String()
152+
153+
//
154+
155+
blacklistCmd = app.Command("blacklist", "Blacklist management")
156+
157+
blacklistAdd = blacklistCmd.Command("add", "Blacklist an address for the user")
158+
blacklistAddUser = blacklistAdd.Arg("user", "user").Required().String()
159+
blacklistAddIP = blacklistAdd.Arg("ip", "ip regex").Required().String()
160+
161+
blacklistDel = blacklistCmd.Command("del", "Removes a blacklist from the user")
162+
blacklistDelUser = blacklistDel.Arg("user", "user").Required().String()
163+
blacklistDelIP = blacklistDel.Arg("ip", "ip regex").Required().String()
126164

127165
//
128166

0 commit comments

Comments
 (0)