Config-Pit-0.04 > Config::Pit

名前

Config::Pit - Manage settings

Config::Pit - 設定管理

概要

  use Config::Pit;

  my $config = pit_get("example.com", require => {
    "username" => "your username on example",
    "password" => "your password on example"
  });
  # if the fields are not set, open setting by $EDITOR
  # with YAML-dumped default values (specified at C<require>).

  # use $config->{username}, $config->{password}
  use Config::Pit;

  my $config = pit_get("example.com", require => {
    "username" => "your username on example",
    "password" => "your password on example"
  });
  # フィールドがセットされていなければ, デフォルト値(C<require>で指定)を
  # YAML形式にしたものが, $EDITORで開かれます.

  # use $config->{username}, $config->{password}

説明

Config::Pit is account setting management library. This library automates editing settings used in scripts.

Original library is written in Ruby and published as pit gem with management command.

You can install it by rubygems:

  $ sudo gem install pit
  $ pit set example.com
  # open setting of example.com with $EDITOR.

And Config::Pit provides ppit command which is pit command written in Perl.

See:

  $ ppit help

Config::Pitはアカウント設定を管理するライブラリです. このライブラリはスクリプト内で利用される設定の編集を自動化します.

オリジナルのものは Rubyで記述され, 管理コマンド pitとして gem形式で公開されています.

それは rubygemsからインストールができます.

  $ sudo gem install pit
  $ pit set example.com
  # open setting of example.com with $EDITOR.

Config::Pitは pitコマンドを Perlで実装した ppitも提供しています.

参照:

  $ ppit help

関数

Config::Pit::get(setting_name, opts)

Get setting named setting_name from current profile.

  my $config = Config::Pit::get("example.com");

This is same as below:

  my $config = pit_get("example.com");

opts:

require

Specify fields you want as key and hint (description or default value) of the field as value.

  my $config = pit_get("example.com", require => {
    "username" => "your username on example.com",
    "password" => "your password on example.com"
  });

require specified, module check the required fields all exist in setting. If not exist, open the setting by $EDITOR with merged setting with current setting.

Config::Pit::set(setting_name, opts)

Set setting named setting_name to current profile.

  Config::Pit::set("example.com"); #=> will open setting with $EDITOR

opts:

data
  Config::Pit::set("example.com", data => {
    username => "foobar",
    password => "barbaz",
  });

When data specified, will not open $EDITOR and set the data directly.

config
  Config::Pit::set("example.com", config => {
    username => "config description or default value",
    password => "same as above",
  });

Open $EDITOR with merged setting with specified config.

Config::Pit::switch(profile_name);

Switch profile to profile_name.

Profile is setting set:

  $ pit get foobar
  # foo bar...

  $ pit switch devel
  Switch profile to devel

  $ pit get foobar
  # bar baz

  $ pit switch
  Switch profile to default

  $ pit get foobar
  # foo bar...

Config::Pit::get(setting_name, opts)

setting_nameという名前の設定を現在のプロファイルから取得する.

  my $config = Config::Pit::get("example.com");

以下の場合も同様のことを行います.

  my $config = pit_get("example.com");

opts:

require

キーとして必要となるフィールドとフィールドの値のヒント(説明かデフォルト値)を指定します.

  my $config = pit_get("example.com", require => {
    "username" => "your username on example.com",
    "password" => "your password on example.com"
  });

requireが指定されたとき, モジュールは設定に必要となるフィールドがすべて存在するかを確認します.もしフィールドが存在しなければ, 指定した設定を $EDITORで開き, 現在の設定にマージします.

Config::Pit::set(setting_name, opts)

setting_nameという名前の設定を, 現在のプロファイルにセットします.

  Config::Pit::set("example.com"); #=> $EDITORで設定が開かれます.

opts:

data
  Config::Pit::set("example.com", data => {
    username => "foobar",
    password => "barbaz",
  });

dataが指定されたとき, $EDITORを使わずに値を直接セットします.

config
  Config::Pit::set("example.com", config => {
    username => "config description or default value",
    password => "same as above",
  });

指定した設定を $EDITORで開き, 現在の設定にマージします.

Config::Pit::switch(profile_name);

profile_nameにプロファイルを切り替えます.

プロファイルは設定の集合です:

  $ pit get foobar
  # foo bar...

  $ pit switch devel
  プロファイルを develに切り替える.

  $ pit get foobar
  # bar baz

  $ pit switch
  プロファイルをデフォルトのものに切り替える.

  $ pit get foobar
  # foo bar...

作者

cho45 <cho45@lowreal.net>

ライセンス

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

http://lowreal.rubyforge.org/pit/ is pit in Ruby.

bin/ppit is pit command in Perl.

http://lowreal.rubyforge.org/pit/は pitの Rubyによる実装です.

bin/ppitは pitコマンドの Perlによる実装です.