'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'
my %BOOLEAN_ARGS = (
'help' => 1,
'version' => 1,
+ 'bare' => 1,
'is-open' => 1,
'is-closed' => 1,
'is-mine' => 1,
}
# 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
=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
Summary: Write a default .cil file so --commands work
-Status: New
+Status: Finished
CreatedBy: Nigel McNie <nigel@mcnie.name>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
+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:
}
# 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