Skip to content

Commit

Permalink
feat: mark --server and --tag as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
vimiix committed Jun 12, 2024
1 parent 9e7d1be commit bb268b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ then you can get ssx binary in **dist** directory.
### Add a new entry

```bash
ssx [-s] [USER@]HOST[:PORT] [-k IDENTITY_FILE]
ssx [USER@]HOST[:PORT] [-k IDENTITY_FILE]
```

If given address matched an exist entry, ssx will login directly.
Expand Down Expand Up @@ -87,10 +87,6 @@ Once we tag the entry, we can log in through the tag later.
### Login
If more than one flag of `-i`, `-s` ,`-t` specified,
priority is `ENTRY_ID > ADDRESS > TAG_NAME`
If not specified any flag, ssx will treat the second argument as a keyword for searching from host and tags, if not matched any entry, ssx will treat it as a new entry, and try to login.
```bash
Expand All @@ -101,10 +97,10 @@ ssx
ssx -i <ID>
# login by address, support partial words
ssx [-s] <ADDRESS>
ssx <ADDRESS>
# login by tag
ssx [-t] <TAG>
ssx <TAG>
```
### Execute command
Expand Down
13 changes: 5 additions & 8 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ make ssx
### 添加新条目(登录一次即代表新增)

```bash
ssx [-s] [USER@]HOST[:PORT] [-k IDENTITY_FILE]
ssx [USER@]HOST[:PORT] [-k IDENTITY_FILE]
```

> 如果给定的地址与一个存在的条目匹配,ssx 将直接登录。
Expand Down Expand Up @@ -113,14 +113,11 @@ ssx tag -i <ENTRY_ID> [-t TAG1 [-t TAG2 ...]] [-d TAG3 [-d TAG4 ...]]
当我们完成对服务器的打标签后,比如假设增加了一个 `centos` 的标签,那么我此时就可以通过标签来进行登录了:
```bash
// -t 可省略
ssx [-t] centos
ssx centos
```
### 登录服务器
如果同时指定了 `-i``-s``-t` 参数,优先级为 `ENTRY_ID > ADDRESS > TAG_NAME`
如果没有指定任何参数标志,ssx 将把第二个参数作为搜索关键词,从主机和标签中搜索,如果没有匹配任何条目,ssx将把它作为一个新条目,并尝试登录。
```bash
Expand All @@ -131,10 +128,10 @@ ssx
ssx -i <ID>

# 通过地址登录,支持部分单词
ssx [-s] <ADDRESS>
ssx <ADDRESS>

# 通过标签登录
ssx [-t] <TAG>
ssx <TAG>
```
### 执行命令
Expand All @@ -148,7 +145,7 @@ ssx <TAG> [-c] <COMMAND> [--timeout 30s]
# 例如:登录192.168.1.100,执行命令'pwd':
ssx 1.100 pwd
# 通过 centos 标签执行
ssx centos -c pwd
ssx centos [-c] pwd
```
### 删除服务器条目
Expand Down
14 changes: 11 additions & 3 deletions cmd/ssx/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ func NewRoot() *cobra.Command {
root := &cobra.Command{
Use: "ssx",
Short: "🦅 ssx is a retentive ssh client",
Example: `# If more than one flag of -i, -s ,-t specified, priority is ENTRY_ID > ADDRESS > TAG_NAME
ssx [-i ENTRY_ID] [-s [USER@]HOST[:PORT]] [-k IDENTITY_FILE] [-t TAG_NAME]
Example: `# First login
ssx [USER@]HOST[:PORT]
# Login with proxy server
ssx [-J PROXY_USER@PROXY_HOST:PROXY_PORT] [USER@]HOST[:PORT]]
# You can also skip the parameters and log in directly with host or tag
# After login once, you can login directly with host or tag or specify ID with -i
ssx [USER@]HOST[:PORT]
ssx TAG_NAME
ssx -i ID
# Fuzzy search is also supported
# For example, you want to login to 192.168.1.100 and
Expand Down Expand Up @@ -91,6 +95,10 @@ ssx 100 pwd`,
root.AddCommand(newInfoCmd())
root.AddCommand(newUpgradeCmd())

// no longer needed, hidden them for backwards compatibility
_ = root.Flags().MarkDeprecated("server", "it will remove in the future")
_ = root.Flags().MarkDeprecated("tag", "it will remove in the future")

root.CompletionOptions.HiddenDefaultCmd = true
root.SetHelpCommand(&cobra.Command{Hidden: true})
return root
Expand Down

0 comments on commit bb268b4

Please sign in to comment.