From: Andrew Chilton Date: Thu, 3 Jul 2008 10:53:01 +0000 (+1200) Subject: Nows adds a default .cil file on init, plus --bare option (closes #a90ad11f). X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2b955ce5bd5b48cdc4a2171b66e4fa887ad18ba3;p=cil.git Nows adds a default .cil file on init, plus --bare option (closes #a90ad11f). --- diff --git a/bin/cil b/bin/cil index 5aaa020..eb0c83a 100755 --- a/bin/cil +++ b/bin/cil @@ -57,6 +57,7 @@ my @IN_OPTS = ( 'assigned-to>a',# for 'summary', 'list' # booleans + 'bare', # for 'init' 'is-open', # for 'summary', 'list' 'is-closed', # for 'summary', 'list' 'is-mine', # for 'summary', 'list' @@ -67,6 +68,7 @@ my @IN_OPTS = ( my %BOOLEAN_ARGS = ( 'help' => 1, 'version' => 1, + 'bare' => 1, 'is-open' => 1, 'is-closed' => 1, 'is-mine' => 1, @@ -138,9 +140,29 @@ sub cmd_init { } # create a .cil file here also - unless ( touch $config ) { - rmdir $issues_dir; - fatal("couldn't create a '$config' file"); + if ( $args->{bare} ) { + unless ( touch $config ) { + rmdir $issues_dir; + fatal("couldn't create a '$config' file"); + } + } + else { + # write a default .cil file + write_file($config, <<'CONFIG'); +StatusStrict: 1 +StatusAllowedList: New +StatusAllowedList: InProgress +StatusAllowedList: Finished +StatusOpenList: New +StatusOpenList: InProgress +StatusClosedList: Finished +LabelStrict: 1 +LabelAllowedList: Type-Enhancement +LabelAllowedList: Type-Defect +LabelAllowedList: Priority-High +LabelAllowedList: Priority-Medium +LabelAllowedList: Priority-Low +CONFIG } # add a README.txt so people know what this is about @@ -1081,11 +1103,15 @@ and attachments as local files which you can check in to your repository. =over -=item init [--path=PATH] +=item init [--path=PATH] [--bare] Creates a local '.cil' file and an 'issues' directory. If PATH is specified, the config file and directory will be created in the destination directory. +Usually, cil will write a small C<.cil> file such that you can use various +filter commands immediately and can also serve as an example config file. Using +C<--bare> just touches the C<.cil> config file ready for your own manipulation. + =item summary [filters] Displays a one line summary for each issue. You may filter on both the Status diff --git a/issues/c_a8edef8d.cil b/issues/c_a8edef8d.cil new file mode 100644 index 0000000..d395555 --- /dev/null +++ b/issues/c_a8edef8d.cil @@ -0,0 +1,7 @@ +Issue: a90ad11f +CreatedBy: Andrew Chilton +Inserted: 2008-07-03T10:48:45 +Updated: 2008-07-03T10:49:42 + +Added a default .cil file when creating a repo. Also allows the '--bare' option +so that advanced users can do what they like. diff --git a/issues/i_a90ad11f.cil b/issues/i_a90ad11f.cil index e02b869..ae4c429 100644 --- a/issues/i_a90ad11f.cil +++ b/issues/i_a90ad11f.cil @@ -1,10 +1,11 @@ Summary: Write a default .cil file so --commands work -Status: New +Status: Finished CreatedBy: Nigel McNie AssignedTo: Andrew Chilton +Comment: a8edef8d Comment: d6ee2369 Inserted: 2008-07-02T12:22:45 -Updated: 2008-07-02T12:42:18 +Updated: 2008-07-03T10:52:32 When I tried to use cil for the first time, I did: diff --git a/lib/CIL.pm b/lib/CIL.pm index ee85064..e2aee9d 100644 --- a/lib/CIL.pm +++ b/lib/CIL.pm @@ -217,19 +217,26 @@ sub read_config_file { } # set some defaults if we don't have any of these - foreach my $key ( keys %$defaults ) { - $cfg->{$key} ||= $defaults->{$key}; - } + %$cfg = (%$defaults, %$cfg); # for some things, make a hash out of them foreach my $hash_name ( @config_hashes ) { - my $h = {}; - my @list = ref $cfg->{"${hash_name}List"} eq 'ARRAY' ? @{$cfg->{"${hash_name}List"}} : $cfg->{"${hash_name}List"}; - foreach my $thing ( @list ) { - $h->{$thing} = 1; + # if we have nothing in the cfg hash already, set it to empty and move on + unless ( exists $cfg->{"${hash_name}List"} ) { + $cfg->{$hash_name} = {}; + next; } + + # if we only have a single item, turn it into an array first + my $key = "${hash_name}List"; + $cfg->{$key} = [ $cfg->{$key} ] unless ref $cfg->{$key} eq 'ARRAY'; + + # loop through all the items making up the hash + my $h = {}; + $h->{$_} = 1 + for @{ $cfg->{$key} }; $cfg->{$hash_name} = $h; - undef $cfg->{"${hash_name}List"}; + undef $cfg->{$key}; } # set each config item