From fcc7366f832d64266f5bb4593d89569e6a8c293d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 24 Feb 2021 14:37:16 -0500 Subject: [PATCH] bin/hey: derive target host from --flake argument --- bin/hey | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/hey b/bin/hey index e005310f..20a0080d 100755 --- a/bin/hey +++ b/bin/hey @@ -27,7 +27,7 @@ module Hey extend self Command = Struct.new(:name, :desc, :args, :opts, :fn) - @@opts = { flake: File.expand_path('../', File.dirname(__FILE__)) } + @@opts = {} @@alias = {} @@commands = {} @@cli = nil @@ -358,6 +358,12 @@ module Hey opt.on(*%w{-i -A -q -e -p}, "Forward to nix-env") { sh ["nix-env", *ARGV]; exit } end opts.order!(args, into: @@opts) + if @@opts[:flake] and @@opts[:flake].include? "#" + @@opts[:flake], @@opts[:host] = @@opts[:flake].split '#' + end + if not @@opts[:flake] or @@opts[:flake].empty? + @@opts[:flake] = File.expand_path('../', File.dirname(__FILE__)) + end begin args.unshift("help") if @@opts[:help]