Skip to content

Commit

Permalink
Initial 'fling open' command
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Arcieri committed Jun 24, 2015
1 parent a35bed1 commit 27d0951
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions fling.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "colorize"
spec.add_runtime_dependency "base32"
spec.add_runtime_dependency "rbnacl-libsodium"
spec.add_runtime_dependency "launchy"

spec.add_development_dependency "bundler", "~> 1.9"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
25 changes: 25 additions & 0 deletions lib/fling/cli.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "fling"
require "thor"
require "uri"
require "cgi"
require "net/http"
require "yaml"

Expand Down Expand Up @@ -82,5 +83,29 @@ def config(file_or_uri)
say "Created #{config_dir}!"
say "Start Tahoe by running 'tahoe start'"
end

desc "open [ALIAS]", "Open the Tahoe-LAFS web UI (possibly showing a particular alias)"
def open(alias_name = nil)
require "launchy"
uri = "http:https://127.0.0.1:3456"

if alias_name
aliases = YAML.load_file(File.expand_path("~/.tahoe/private/aliases"))
unless aliases[alias_name]
say "Error: no such alias: #{alias_name}"
say "Valid aliases are:"

aliases.keys.each do |key|
say " #{key}"
end

exit 1
end

uri += "/uri/#{CGI.escape(aliases[alias_name])}"
end

Launchy.open(uri)
end
end
end

0 comments on commit 27d0951

Please sign in to comment.