mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
feat(xbar/mise): improve display of updates to mise itself
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
# rubocop:disable Layout/LineLength
|
# rubocop:disable Layout/LineLength
|
||||||
|
|
||||||
# <xbar.title>Mise Updates</xbar.title>
|
# <xbar.title>Mise Updates</xbar.title>
|
||||||
# <xbar.version>v1.0.1</xbar.version>
|
# <xbar.version>v1.1.0</xbar.version>
|
||||||
# <xbar.author>Jim Myhrberg</xbar.author>
|
# <xbar.author>Jim Myhrberg</xbar.author>
|
||||||
# <xbar.author.github>jimeh</xbar.author.github>
|
# <xbar.author.github>jimeh</xbar.author.github>
|
||||||
# <xbar.desc>List and manage outdated tools installed with mise</xbar.desc>
|
# <xbar.desc>List and manage outdated tools installed with mise</xbar.desc>
|
||||||
@@ -178,9 +178,22 @@ module Xbar
|
|||||||
end
|
end
|
||||||
|
|
||||||
def item(label = nil, **props)
|
def item(label = nil, **props)
|
||||||
print_item(label, **props) if !label.nil? && !label.empty?
|
return if label.nil? || label.empty?
|
||||||
|
|
||||||
yield(sub_printer) if block_given?
|
props = normalize_props(props.dup)
|
||||||
|
alt = props.delete(:alt)
|
||||||
|
nested_items = props.delete(:nested) || :both
|
||||||
|
|
||||||
|
yield_main = block_given? && [:main, :both].include?(nested_items)
|
||||||
|
yield_alt = block_given? && [:alt, :both].include?(nested_items)
|
||||||
|
|
||||||
|
print_item(label, **props)
|
||||||
|
yield(sub_printer) if yield_main
|
||||||
|
|
||||||
|
return if alt.nil? || alt.strip.empty?
|
||||||
|
|
||||||
|
print_item(alt, **props.merge(alternate: true))
|
||||||
|
yield(sub_printer) if yield_alt
|
||||||
end
|
end
|
||||||
|
|
||||||
def separator
|
def separator
|
||||||
@@ -191,22 +204,14 @@ module Xbar
|
|||||||
private
|
private
|
||||||
|
|
||||||
def print_item(text, **props)
|
def print_item(text, **props)
|
||||||
props = props.dup
|
|
||||||
alt = props.delete(:alt)
|
|
||||||
|
|
||||||
output = [text]
|
output = [text]
|
||||||
unless props.empty?
|
unless props.empty?
|
||||||
props = normalize_props(props)
|
|
||||||
output << PARAM_SEP
|
output << PARAM_SEP
|
||||||
output += props.map { |k, v| "#{k}=\"#{v}\"" }
|
output += props.map { |k, v| "#{k}=\"#{v}\"" }
|
||||||
end
|
end
|
||||||
|
|
||||||
$stdout.print(SUB_STR * nested_level, output.join(' '))
|
$stdout.print(SUB_STR * nested_level, output.join(' '))
|
||||||
$stdout.puts
|
$stdout.puts
|
||||||
|
|
||||||
return if alt.nil? || alt.empty?
|
|
||||||
|
|
||||||
print_item(alt, **props.merge(alternate: true))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def plugin_refresh_uri
|
def plugin_refresh_uri
|
||||||
@@ -266,6 +271,11 @@ module Xbar
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
|
||||||
|
# Mise module contains classes for managing Mise tools.
|
||||||
module Mise
|
module Mise
|
||||||
module Helpers
|
module Helpers
|
||||||
def relative_path(path)
|
def relative_path(path)
|
||||||
@@ -621,11 +631,22 @@ module Mise
|
|||||||
|
|
||||||
# Show mise version status and, if outdated, a self-update action.
|
# Show mise version status and, if outdated, a self-update action.
|
||||||
if mise_outdated?
|
if mise_outdated?
|
||||||
printer.item(
|
printer.item("mise (1)") do |printer|
|
||||||
"⬆️ Update mise (#{mise_current_version} → #{mise_latest_version})",
|
printer.item(
|
||||||
terminal: true, refresh: true,
|
"⬆️ Update (#{mise_current_version} → #{mise_latest_version})",
|
||||||
shell: [mise_path, 'self-update', '--yes']
|
terminal: true, refresh: true,
|
||||||
)
|
shell: [mise_path, 'self-update', '--yes']
|
||||||
|
)
|
||||||
|
printer.sep
|
||||||
|
printer.item(
|
||||||
|
"📝 Changelog (#{mise_latest_version})",
|
||||||
|
href: "https://github.com/jdx/mise/blob/v#{mise_latest_version}/CHANGELOG.md"
|
||||||
|
)
|
||||||
|
printer.item(
|
||||||
|
'📦 Releases',
|
||||||
|
href: "https://github.com/jdx/mise/releases"
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print_tools(printer)
|
print_tools(printer)
|
||||||
|
|||||||
Reference in New Issue
Block a user