show

command module
v0.0.0-...-345b6a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 6 Imported by: 0

README

Show

Go License

中文 | English

一个兼容多平台的、丰富的、多功能终端工具集。

安装

$ GO111MODULE=on go install github.com/anqiansong/show@latest

配置

show 应用可以修改日志的输出目录、设置主题的存放目录,需要展示的主题名称,主题模式。

# show 的配置文件采用的是 toml 格式,如需要了解 toml,请跳转至 https://toml.io
# 例子: 配置日志输出目录
# [log]
# mode = "file" # console: 输出到控制台, file: 输出到文件
# dir = "/Users/foo/.show/log" # 指定日志路径

# 例子: 配置文本输出的高亮主题
# [theme]
# 以下示例配置对应的主题文件映射为: /Users/foo/.show/theme/default.theme
# 主题的目录,可以包含类似 $HOME、${HOME} 这样的环境变量
# dir = "/Users/foo/.show/theme"
# 主题模式:none: 不使用高亮输出, rand: 随机选择主题,每次输出的主题颜色都随机, static: 静态指定,如果主题模式指定为 static,则 name 需要指定主题名称
# mode = "static" 
# 主题名称,如果主题模式为 static,此字段不设置,默认会选择 default 主题
# 当指定主题名称在指定路径下不存在时,则会去 https://github.com/anqiansong/show/tree/main/resource/theme 中寻找与
# name 对应的主题并下载,填写不存在的名称,则本地主题设置不生效。
# 注意:不要携带文件后缀
# name = "default" 

# 以下为默认配置
[log]
mode = "file"
dir = "$HOME/.show/log"

[theme]
dir = "$HOME/.show/theme"
mode = "static"
name = "default"

以下为show 默认路径下的相关文件

.
├── config
│   └── show.conf
├── log
│   └── access.log
└── theme
    └── default.theme

主题样式

目前已经提供了多款常用主题,详情见 主题样式

自定义高亮主题

在 show 中,你可以自定义自己的主题,主题文件采用 xml 格式来定义,所有主题必须要 .theme 为后缀名,否则会找不到文件, 以下为默认主题文件:

<?xml version="1.0" encoding="UTF-8" ?>
<theme profile="ansi256">
    <meta>
        <bold>true</bold>
        <italic>true</italic>
    </meta>
    <color>
        <keyword>#0033B3</keyword>
        <number>#1750EB</number>
        <string>#067D17</string>
        <bool>#1750EB</bool>
        <comment>#8C8C8C</comment>
        <constant>#871094</constant>
        <func-declare>#00627A</func-declare>
    </color>
</theme>

主题文件内容以 theme 为根标签开始,目前包含如下子节点(会持续添加):

属性
  • profile 颜色属性,枚举值 ansi|ansi256|trueColor
    • ansi 8 色
    • ansi256 色,默认值
    • trueColor 真彩(该模式不是所有的 terminal 都支持,目前已知 iTerm 支持)
节点
  • bold 是否加粗
  • italic 是否斜体
  • keyword 关键字颜色
  • plain 普通文本颜色
  • number 数字颜色
  • string 字符串颜色
  • bool bool 值颜色
  • parentheses 圆括号颜色
  • brackets 中括号颜色
  • braces 大括号颜色
  • variable 变量颜色
  • identifier ID 类型颜色(同 plain)
  • comment 注释颜色
  • dot 圆点符号.颜色
  • colon 分隔符;颜色
  • comma 逗号,颜色
  • constant 常量颜色
  • func-declare 函数名称颜色
  • func-call 调用函数颜色
  • parameter 函数参数颜色

节点之间的值为具体的十六进制颜色值,由于 terminal 支持的色彩是 ANSI256色,因此 show 会将十六进制颜色转换与与 ANSI256 接近的颜色,其中节点之间的颜色值为 none 或者 没有添加对应节点的颜色则不进行渲染

自定好主题 xml 文件后,需要将该文件以 .theme 为后缀的文件名,然后将其放到配置中指定的目录下即可, 下次会根据配置自动生效。

温馨提示

不是所有的字段都要配置主题色,如果不需要的可以不用在 xml 中声明,show 不会对其进行颜色渲染

注意

主题仅对 unix-like 生效,暂不支持 Windows

工具集

  • date 日期显示
  • json json 解析、美化输出,类似 jq,支持从网络获取数据并解析
  • yaml yaml 解析、美化输出,支持从网络获取数据并解析(暂不支持高亮)
  • toml toml 解析、美化输出,支持从网络获取数据并解析
  • xml xml、美化输出,支持从网络获取数据并解析
  • More ...

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
date
Package date supports viewing date, formatted output, and conversion between timestamp and date, for example, if you want to know what date it is, you can execute a simple command "show date now", and the sample output like "2021-11-29 13:54:28.078364 +0800 CST m=+0.000846726", if you want to show as timestamp, you can execute command "show date now --timestamp", sometimes, we usually need to convert both timestamp and date, the best command "show date convert" maybe the best choice, for more information, you can execute "show date --help" to see.
Package date supports viewing date, formatted output, and conversion between timestamp and date, for example, if you want to know what date it is, you can execute a simple command "show date now", and the sample output like "2021-11-29 13:54:28.078364 +0800 CST m=+0.000846726", if you want to show as timestamp, you can execute command "show date now --timestamp", sometimes, we usually need to convert both timestamp and date, the best command "show date convert" maybe the best choice, for more information, you can execute "show date --help" to see.
json
Package json is used to beautify the json output.
Package json is used to beautify the json output.
toml
Package toml is used to beautify the output of toml.
Package toml is used to beautify the output of toml.
writer
Package writer opens a goroutine to receive data from the main worker.
Package writer opens a goroutine to receive data from the main worker.
xml
yaml
Package yaml is used to beautify the output of yaml.
Package yaml is used to beautify the output of yaml.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL