# 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