Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
use emoji as icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ingbyr committed Sep 14, 2022
1 parent 4240601 commit 38a67f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 53 deletions.
1 change: 1 addition & 0 deletions gohost/service.go
Expand Up @@ -214,4 +214,5 @@ func (s *Service) EnableNode(node *TreeNode) {
s.EnableNode(child)
}
}

}
40 changes: 3 additions & 37 deletions readme.md
Expand Up @@ -10,43 +10,9 @@ Gohost is a simple host switcher tool supporting Windows, Linux and macOS.
- For Windows user: open console in admin mode.
- For Linux and macOS user: use `sudo gohost` or login as root

**To display icon correctly**

## Usage

### Manage Host File

| Description | Command | Example |
|------------------|--------------------------------------------------------|----------------------------------|
| Create host file | `gohost new HOST_NAME GROUP_NAME_1[,GROUP_NAME_2,...]` | `gohost new file1 group1,group2` |
| Edit host file | `gohost edit HOST_NAME` | `gohost edit file1` |
| Delete host file | `gohost rm HOST_NAME_1[,HOST_NAME_2,...]` | `gohost rm file1,file2` |
| List host file | `gohost ls -a(-all)` | `gohost ls -a` |
| Rename host file | `gohost mv HOST_NAME NEW_HOST_NAME` | `gohost mv file1 newFile` |


### Manage Group

| Description | Command | Example |
|-----------------------|--------------------------------------------------------------------|------------------------------------|
| Add group for host | `gohost cg HOST_NAME -a(--add) GROUP_NAME_1[,GROUP_NAME_2,...]` | `gohost cg file1 -a group3,group4` |
| Remove group for host | `gohost cg HOST_NAME -d(--delete) GROUP_NAME_1[,GROUP_NAME_2,...]` | `gohost cg file1 -d group3,group4` |
| List group | `gohost ls` | `gohost ls` |
| Rename group | `gohost mv -g(--group) GROUP_NAME NEW_GROUP_NAME` | `gohost mv -g group1 newGroup` |
| Delete group | `gohost rm -g GROUP_NAME` | `gohost rm -g group3` |
- For Windows user: please use terminal which supports unicode sush as `Windows Terminal`

## Usage

### Apply Group

| Description | Command | Example |
|-----------------------|----------------------------------------|------------------------|
| Apply to system host | `gohost use GROUP_NAME` | `gohost use group1` |
| Display group content | `gohost use GROUP_NAME -s(--simulate)` | `gohost use group1 -s` |
| Display system host | `gohost sys` | `gohost sys` |


### Config

| Description | Command | Example |
|---------------|---------------------------------------------|------------------------------|
| Show version | `gohost version` | `gohost version` |
| Change editor | `gohost cfg editor '[EDITOR ARG0 ARG1...]'` | `gohost cfg editor 'vim -n'` |
5 changes: 0 additions & 5 deletions tui/node_view.go
Expand Up @@ -62,11 +62,6 @@ func NewNodeView(model *Model) *NodeView {
case gohost.Host:
parent = selectedNode.Parent()
}
// Unfold parent first
if parent.IsFolded() {
svc.LoadNodesByParent(parent)
parent.SetFolded(false)
}

// Save node
switch nodeTypeChoices.SelectedItem() {
Expand Down
24 changes: 13 additions & 11 deletions tui/tree_view.go
Expand Up @@ -36,34 +36,36 @@ func (d *nodeItemDelegate) Render(w io.Writer, m list.Model, index int, item lis
}

var str string
var enableIcon string
if node.IsEnabled() {
str = "+" + str
enableIcon = "✅"
} else {
str = "-" + str
enableIcon = ""
}

var nodeIcon string
switch node.Node.(type) {
case *gohost.Group:
var icon string
if node.IsFolded() {
icon = "| "
nodeIcon = "📁 "
} else {
icon = "/ "
nodeIcon = "📂 "
}
str = strings.Repeat(" ", node.Depth()) + str + icon + node.Title()
case *gohost.SysHost:
str = strings.Repeat(" ", node.Depth()) + str + "* " + node.Title()
nodeIcon = "👻 "
case *gohost.LocalHost:
str = strings.Repeat(" ", node.Depth()) + str + "# " + node.Title()
nodeIcon = "📝 "
case *gohost.RemoteHost:
str = strings.Repeat(" ", node.Depth()) + str + "@" + node.Title()
nodeIcon = "🌐 "
}

var cursor string
if m.Index() == index {
str = "> " + str
cursor = "> "
} else {
str = " " + str
cursor = " "
}
str = cursor + strings.Repeat(" ", node.Depth()) + nodeIcon + node.Title() + enableIcon

strLen := lipgloss.Width(str)
if strLen > d.width {
Expand Down

0 comments on commit 38a67f2

Please sign in to comment.