Sha256: 1d2bb6ad16b30d1c47e1487f59203f76e4776ad8ddd3e601239ae197ee7e3367

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# encoding: UTF-8
# frozen_string_literal: true

require 'nrser/refinements/types'
using NRSER::Types


# Namespace
# =======================================================================

module  Locd
module  CLI
module  Command


# Definitions
# =======================================================================

class Agent < Base
  
  desc              "open",
                    "Open an agent's URL in the browser"

  include_shared    t[ groups: t.HasAny( :pattern, :multi, :start ) ]

  option            :start,
    desc:           %{ Start any stopped agents before opening },
    type:           :boolean,
    default:        true
  
  def open
    Locd::Agent::Proxy.get!.ensure_running
    
    find_multi!( pattern ).each do |agent|
      if options[:start]
        agent.ensure_running( **option_kwds( groups: :start ) )
      end
      
      Cmds! "open %s", agent.url
      
      logger.info "Opened agent `#{ agent.label }` at #{ agent.url }"
    end
  end

end


# /Namespace
# =======================================================================

end # module  Command
end # module  CLI
end # module  Locd

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locd-0.1.13 lib/locd/cli/command/agent/open.rb