Skip to content

Commit

Permalink
Merge pull request #9 from hlhr202/develop
Browse files Browse the repository at this point in the history
Feature: implement CLI
  • Loading branch information
hlhr202 committed Apr 17, 2024
2 parents 93f499f + 110110f commit b40c1dc
Show file tree
Hide file tree
Showing 23 changed files with 1,452 additions and 601 deletions.
72 changes: 65 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
resolver = "2"
members = [
"crates/openconnect-build",
"crates/openconnect-sys",
"crates/openconnect-core",
"crates/openconnect-gui/src-tauri",
"crates/openconnect-cli",
"crates/openconnect-oidc",
]

[workspace.dependencies]
Expand All @@ -15,7 +15,9 @@ reqwest = { version = "0.12.2", features = [
"blocking",
"cookies",
] }
base64 = "0.22.0"
clap = { version = "4.5.4", features = ["derive"] }
clap_complete = "4.5.2"
tokio = { version = "1.37.0", features = ["full"] }
tokio-serde = { version = "0.9.0", features = ["json", "serde"] }
tokio-util = { version = "0.7.10", features = ["codec"] }
Expand Down Expand Up @@ -46,4 +48,4 @@ machine-uid = "0.5.1"
chacha20poly1305 = "0.10.1"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"
tracing-appender = "0.2.3"
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ This is a cross-platform GUI client for OpenConnect, written in Rust and designe
Usage: openconnect <COMMAND>
Commands:
start Connect to a VPN server and run in daemon mode [aliases: connect, run]
status Get the current VPN connection status [aliases: info, stat]
stop Close the current connection and exit the daemon process [aliases: kill, disconnect]
add Add new VPN server configuration to local config file [aliases: new, create, insert]
delete Delete a VPN server configuration from local config file [aliases: rm, remove, del]
list List all VPN server configurations in local config file [aliases: ls, l]
logs Show logs of the daemon process [aliases: log]
help Print this message or the help of the given subcommand(s)
start Connect to a VPN server and run in daemon mode [aliases: connect, run]
status Get the current VPN connection status [aliases: info, stat]
stop Close the current connection and exit the daemon process [aliases: kill, disconnect]
add Add new VPN server configuration to local config file [aliases: new, create, insert]
import Import VPN server configurations from a base64 encoded string
export Export VPN server configurations to a base64 encoded string
delete Delete a VPN server configuration from local config file [aliases: rm, remove, del]
list List all VPN server configurations in local config file [aliases: ls, l]
logs Show logs of the daemon process [aliases: log]
gen-complete Generate shell completion script
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
Expand Down Expand Up @@ -90,6 +93,24 @@ This is a cross-platform GUI client for OpenConnect, written in Rust and designe
-h, --help Print help
```

### Generate shell completion script

- ZSH (Oh My Zsh!)

```bash
mkdir -p ~/.oh-my-zsh/custom/plugins/openconnect
openconnect gen-complete zsh > ~/.oh-my-zsh/custom/plugins/openconnect/openconnect.plugin.zsh
echo "plugins+=(openconnect)" >> ~/.zshrc
```

- Bash

```bash
mkdir -p ~/.bash_completion
openconnect gen-complete bash > ~/.bash_completion/openconnect
echo "source ~/.bash_completion/openconnect" >> ~/.bashrc
```

## Build

- Read the [System Requirements](./crates/openconnect-sys/README.md) for environment setup
Expand Down Expand Up @@ -139,8 +160,9 @@ Special thanks to (MORE THAN) the following projects and technologies for making
- [x] implement oidc login
- [x] implement logs
- [x] tracing file rotation
- [ ] optimize log search
- [x] implement CLI
- [x] Add/Remove configurations
- [x] Daemon mode
- [x] Password login
- [ ] OIDC login
- [x] OIDC login
10 changes: 0 additions & 10 deletions crates/openconnect-build/Cargo.toml

This file was deleted.

71 changes: 0 additions & 71 deletions crates/openconnect-build/src/lib.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/openconnect-build/src/main.rs

This file was deleted.

7 changes: 6 additions & 1 deletion crates/openconnect-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ version = "0.1.1"
edition = "2021"

[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
clap = { workspace = true }
clap_complete = { workspace = true }
tokio = { workspace = true }
tokio-serde = { workspace = true }
tokio-util = { workspace = true }
futures = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
libc = { workspace = true }
openconnect-oidc = { path = "../openconnect-oidc", version = "0.1.1" }
openconnect-core = { path = "../openconnect-core", version = "0.1.1" }
sudo = { workspace = true }
tracing = { workspace = true }
thiserror = { workspace = true }
chrono = { workspace = true }
home = { workspace = true }
comfy-table = "7.1.1"
comfy-table = "7.1.1"
dialoguer = "0.11.0"
Loading

0 comments on commit b40c1dc

Please sign in to comment.