Skip to content

Commit 9fe8c56

Browse files
committed
Add orders command, version subcommand, and make install target
- Add `lw orders` subcommand covering account orders and product catalog (dedicated servers and VPS browsing/ordering) - Add `lw version` subcommand so version works as both flag and command - Add `make install` target to install binary to /usr/local/bin - Add `make uninstall` target and update README with installation docs Made-with: Cursor
1 parent 9fb3232 commit 9fe8c56

5 files changed

Lines changed: 463 additions & 5 deletions

File tree

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
22

3-
.PHONY: build install test vet lint clean
3+
PREFIX ?= /usr/local
4+
5+
.PHONY: build install uninstall test vet lint clean
46

57
build:
68
go build -ldflags "-X github.com/kernel/leaseweb-cli/pkg/cmd.Version=$(VERSION)" -o lw ./cmd/lw
79

8-
install:
9-
go install -ldflags "-X github.com/kernel/leaseweb-cli/pkg/cmd.Version=$(VERSION)" ./cmd/lw
10+
install: lw
11+
install -d $(DESTDIR)$(PREFIX)/bin
12+
install -m 755 lw $(DESTDIR)$(PREFIX)/bin/lw
13+
14+
lw: $(shell find . -name '*.go' -not -path './vendor/*')
15+
go build -ldflags "-X github.com/kernel/leaseweb-cli/pkg/cmd.Version=$(VERSION)" -o lw ./cmd/lw
16+
17+
uninstall:
18+
rm -f $(DESTDIR)$(PREFIX)/bin/lw
1019

1120
test:
1221
go test ./... -v

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ brew install kernel/tap/lw
1616
go install github.com/kernel/leaseweb-cli/cmd/lw@latest
1717
```
1818

19+
### From source
20+
21+
```sh
22+
git clone https://github.com/kernel/leaseweb-cli.git
23+
cd leaseweb-cli
24+
make build && sudo make install
25+
```
26+
27+
This builds the binary and installs it to `/usr/local/bin/lw`. To uninstall: `sudo make uninstall`.
28+
1929
### Binary releases
2030

2131
Download pre-built binaries from the [Releases](https://github.com/kernel/leaseweb-cli/releases) page.
@@ -102,6 +112,7 @@ COMMANDS:
102112
ips Manage IP addresses
103113
load-balancers, lb Manage public cloud load balancers
104114
network-equipment, ne Manage dedicated network equipment
115+
orders Manage orders and product catalog
105116
private-clouds, pc Manage private clouds
106117
private-networks, pn Manage private networks
107118
remote-management, rm Manage OpenVPN remote management
@@ -153,6 +164,15 @@ lw instances list
153164
lw instances regions
154165
lw instances types --region eu-west-3
155166
167+
# Orders
168+
lw orders list
169+
lw orders get 41002016
170+
171+
# Browse product catalog
172+
lw orders products ds list
173+
lw orders products ds get SERVER-1 --location AMS-01
174+
lw orders products vps list
175+
156176
# DNS management
157177
lw domains list
158178
lw domains dns example.com
@@ -208,6 +228,7 @@ Use `lw <command> --help` for details on any subcommand. Here's a summary:
208228
| `invoices` | | List, get, PDF download, proforma, CSV export |
209229
| `ips` | | List, get, update, null route, reverse lookup (IPv4 + IPv6) |
210230
| `load-balancers` | `lb` | CRUD, listeners, IPs, metrics, monitoring |
231+
| `orders` | | List orders, browse product catalog, order dedicated servers and VPS |
211232
| `network-equipment` | `ne` | CRUD equipment, credentials, IPs, power, null routes |
212233
| `private-clouds` | `pc` | CRUD private clouds, credentials, metrics |
213234
| `private-networks` | `pn` | CRUD networks, servers, DHCP reservations |
@@ -225,8 +246,11 @@ Use `lw <command> --help` for details on any subcommand. Here's a summary:
225246
# Build
226247
make build
227248

228-
# Install to $GOPATH/bin
229-
make install
249+
# Install to /usr/local/bin (build first as your user)
250+
make build && sudo make install
251+
252+
# Uninstall
253+
sudo make uninstall
230254

231255
# Run tests
232256
make test

pkg/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func init() {
6363
&instancesCmd,
6464
&invoicesCmd,
6565
&ipsCmd,
66+
&ordersCmd,
6667
&loadBalancersCmd,
6768
&networkEquipmentCmd,
6869
&privateCloudsCmd,
@@ -72,6 +73,7 @@ func init() {
7273
&storageCmd,
7374
&trafficPolicyCmd,
7475
&virtualServersCmd,
76+
&versionCmd,
7577
&vpsCmd,
7678
&webhostingCmd,
7779
},

0 commit comments

Comments
 (0)