]> git.mjollnir.org Git - cil.git/commitdiff
Nows adds a default .cil file on init, plus --bare option (closes #a90ad11f).
authorAndrew Chilton <andychilton@gmail.com>
Thu, 3 Jul 2008 10:53:01 +0000 (22:53 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Thu, 3 Jul 2008 10:53:01 +0000 (22:53 +1200)
bin/cil
issues/c_a8edef8d.cil [new file with mode: 0644]
issues/i_a90ad11f.cil
lib/CIL.pm

diff --git a/bin/cil b/bin/cil
index 5aaa020582f2f215b25a6efed19df3fbc0d72f16..eb0c83afef2afa271f2c09c94024e09ccd78872e 100755 (executable)
--- 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 (file)
index 0000000..d395555
--- /dev/null
@@ -0,0 +1,7 @@
+Issue: a90ad11f
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+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.
index e02b869fd49b4d90e94bfb1e95b2cdd583f82402..ae4c42996c58170965f88422ae902961004f5053 100644 (file)
@@ -1,10 +1,11 @@
 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:
 
index ee850644928c82a0c7f7d4866aeb279c6032d2e8..e2aee9d27fa07172f703d6ecad0cd1207cb00953 100644 (file)
@@ -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