add info command

This commit is contained in:
Jorge Morante 2024-11-28 11:20:45 +01:00
parent ab8c4be8c0
commit 33e2f0e0e2
7 changed files with 41 additions and 2 deletions

View file

@ -16,6 +16,8 @@ jobs:
run: apk add --update --upgrade --no-cache --force-overwrite libxml2-dev yaml-dev yaml-static
- name: Build
run: shards build --production --release --static --no-debug
env:
WIZARD_INSTALLATION_METHOD: download-binary
- name: Upload
uses: actions/upload-release-asset@v1.0.1
env:

View file

@ -38,7 +38,7 @@ function install_from_source() {
fi
pushd $CURRENT_DIR > /dev/null
shards build --production
WIZARD_INSTALLATION_METHOD=build-from-source shards build --production
popd > /dev/null
echo "Build complete!"

View file

@ -4,6 +4,10 @@ shards:
git: https://github.com/devnote-dev/cling.git
version: 3.0.0
tablo:
git: https://github.com/hutou/tablo.git
version: 0.10.1
xdg_base_directory:
git: https://github.com/tijn/xdg_base_directory.git
version: 1.0.5+git.commit.60bf28dc060c221d5af52727927e92b840022eb0

View file

@ -12,5 +12,7 @@ dependencies:
version: '>= 3.0.0'
xdg_base_directory:
github: tijn/xdg_base_directory
tablo:
github: hutou/tablo
crystal: 1.14
license: MIT

View file

@ -10,6 +10,7 @@ module Fingers
add_command Fingers::Commands::LoadConfig.new
add_command Fingers::Commands::SendInput.new
add_command Fingers::Commands::Start.new
add_command Fingers::Commands::Info.new
end
def run(arguments, options) : Nil

View file

@ -0,0 +1,30 @@
require "cling"
require "tablo"
class Fingers::Commands::Info < Cling::Command
WIZARD_INSTALLATION_METHOD = {{ env("WIZARD_INSTALLATION_METHOD") }}
def setup : Nil
@name = "info"
end
def run(arguments, options) : Nil
data = [
["tmux-fingers", "#{Fingers::VERSION}"],
["xdg-root-folder", "#{Fingers::Dirs::ROOT}"],
["log-path", "#{Fingers::Dirs::LOG_PATH}"],
["installation-method", "#{WIZARD_INSTALLATION_METHOD || "manual"}"],
["tmux-version", `tmux -V`.chomp],
["crystal-version", Crystal::VERSION]
]
opt_width = data.map { |n| n[0].size }.max
val_width = data.map { |n| n[1].size }.max
table = Tablo::Table.new(data, header_frequency: nil) do |t|
t.add_column("Option", width: opt_width) { |n| n[0] }
t.add_column("Value", width: val_width) { |n| n[1] }
end
puts table
end
end

View file

@ -2,7 +2,7 @@ require "file_utils"
require "xdg_base_directory"
module Fingers::Dirs
TMUX_PID = (ENV["TMUX"] || ",0000").split(",")[1]
TMUX_PID = (ENV.fetch("TMUX", ",0000")).split(",")[1]
XDG = XdgBaseDirectory.app_directories("tmux-fingers")
TMP = Path[File.dirname(File.tempname)]