Skip to content

Commit

Permalink
Add $ flipper show featurename
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Aug 1, 2023
1 parent 1b36ba0 commit e48a03e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/flipper/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'flipper/cli/enable'
require 'flipper/cli/disable'
require 'flipper/cli/list'
require 'flipper/cli/show'
require 'flipper/cli/help'

module Flipper
Expand All @@ -19,6 +20,7 @@ def initialize(**args)
subcommand 'enable', Flipper::CLI::Enable
subcommand 'disable', Flipper::CLI::Disable
subcommand 'list', Flipper::CLI::List
subcommand 'show', Flipper::CLI::Show
subcommand 'help', Flipper::CLI::Help
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/flipper/cli/show.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Flipper
module CLI
class Show < Command
def call(feature)
load_environment!
puts feature_summary(Flipper.feature(feature))
end
end
end
end
9 changes: 9 additions & 0 deletions spec/fixtures/environment.rb
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Placeholder for config/environment.rb

unless ENV["FLIPPER_REQUIRE"]
require 'flipper'
require 'flipper/adapters/pstore'

Flipper.configure do |config|
config.adapter { Flipper::Adapters::PStore.new }
end
end
9 changes: 7 additions & 2 deletions spec/flipper/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@
end

describe "help enable" do

it { should have_attributes(status: 0, stdout: /Usage: flipper enable \[options\] <feature>/) }
it { should have_attributes(status: 0, stdout: /Usage: flipper enable \[options\] <feature>/) }
end

describe "nope" do
it { should have_attributes(status: 1, stderr: /Unknown command: nope/) }
end

describe "show foo" do
before { Flipper.enable :foo }

it { should have_attributes(status: 0, stdout: /foo.*fully enabled/) }
end

def run(argv)
original_stdout = $stdout
original_stderr = $stderr
Expand Down

0 comments on commit e48a03e

Please sign in to comment.