GithubHelp home page GithubHelp logo

isabella232 / stager-client-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from localytics/stager-client

0.0 0.0 0.0 93 KB

Command line interface for working with a Stager server

License: MIT License

Ruby 100.00%

stager-client-1's Introduction

Stager cli

This gem installs a command line interface for working with a Stager instance.

Installation

git clone [email protected]:localytics/stager-cli.git
cd stager-cli
bundle install
rake install
cd pkg
sudo gem install stager-0.0.1.gem

Usage

#display list of available commands
stager

#minimal config
stager configure endpoint=https://your-stager-instance.com/ auth_strategy=Basic #or Github, depends on Stager instance config

Adding Auth Strategies

When adding authentication strategies to Stager it is often useful to add a corresponding auth strategy to the Stager cli gem. This allows you to set the auth_strategy using the stager configure command, and have all requests to Stager automatically amended to include the necessary authentication info.

Adding an auth_strategy is very simple, define a class which inherits from Stager::AuthStrategy in the auth_strategies folder, inside the Stager module namespace, and implement the sign_request_options method.

The class will have access to the current Command instance via the @cli instance variable, and the sign_request_options method will receive one argument, the options hash which is passed to the HTTParty.post call made to a Stager route.

Here's an example auth_strategy that will add foo=bar to the posted params on any call to Stager made using the cli:

module Stager
  class Foobar << AuthStrategy
  
    def sign_request_options(options)
      options[:body][:foo] = bar
    end
  end
end

After saving the above in auth_strategies, and reinstalling the gem, the following is now possible:

stager configure auth_strategy=Foobar
stager launch name_of_image name_of_container #post params automatically include foo=bar

The gem uses Configliere for loading and saving settings from and to local config. The @cli instance variable exposes a save_settings method which persists the current state of the Settings hash to the local config file.

See the Github auth strategy for an example of persisting settings to local config and using them in subsequent calls.

stager-client-1's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.