diff --git a/src/Context.cpp b/src/Context.cpp index cb425cb53..fb8b2ddb7 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -287,7 +287,7 @@ void Context::loadCorrectConfigFile () if (access (file.c_str (), F_OK)) throw std::string ("Could not read configuration file '") + file + "'"; - message (std::string ("Using alternate .taskrc file ") + file); // TODO i18n + header (std::string ("Using alternate .taskrc file ") + file); // TODO i18n config.clear (); // Dump current values. config.setDefaults (); // Add in the custom reports. config.load (file); // Load new file. diff --git a/src/Task.cpp b/src/Task.cpp index 2159521a6..31e7d5695 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -331,7 +331,7 @@ std::string Task::composeCSV () const { std::stringstream out; - out << "'" << id << "',"; + out << id << ","; out << "'" << get ("uuid") << "',"; // No i18n out << "'" << get ("status") << "',"; // No i18n @@ -339,18 +339,43 @@ std::string Task::composeCSV () const std::vector tags; getTags (tags); std::string allTags; - join (allTags, " ", tags); // No i18n + join (allTags, " ", tags); // No i18n out << "'" << allTags << "',"; // No i18n - out << "'" << get ("entry") << "',"; // No i18n - out << "'" << get ("start") << "',"; // No i18n - out << "'" << get ("due") << "',"; // No i18n - out << "'" << get ("recur") << "',"; // No i18n - out << "'" << get ("end") << "',"; // No i18n - out << "'" << get ("project") << "',"; // No i18n - out << "'" << get ("priority") << "',"; // No i18n - out << "'" << get ("fg") << "',"; // No i18n - out << "'" << get ("bg") << "',"; // No i18n + out << get ("entry") << ","; // No i18n + out << get ("start") << ","; // No i18n + + if (has ("due")) + out << "'" << get ("due") << "',"; // No i18n + else + out << ","; // No i18n + + if (has ("recur")) + out << "'" << get ("recur") << "',"; // No i18n + else + out << ","; // No i18n + + out << get ("end") << ","; // No i18n + + if (has ("project")) + out << "'" << get ("project") << "',"; // No i18n + else + out << ","; // No i18n + + if (has ("priority")) + out << "'" << get ("priority") << "',"; // No i18n + else + out << ","; // No i18n + + if (has ("fg")) + out << "'" << get ("fg") << "',"; // No i18n + else + out << ","; // No i18n + + if (has ("bg")) + out << "'" << get ("bg") << "',"; // No i18n + else + out << ","; // No i18n // Convert single quotes to double quotes, because single quotes are used to // delimit the values that need it. diff --git a/src/tests/export.t b/src/tests/export.t index 08a383e4a..6f540b59c 100755 --- a/src/tests/export.t +++ b/src/tests/export.t @@ -46,13 +46,18 @@ qx{../task rc:export.rc export > ./export.txt}; my @lines; if (open my $fh, '<', './export.txt') { - @lines = <$fh>; + while (my $line = <$fh>) + { + next unless $line =~ /^['0-9]/; + push @lines, $line; + } + close $fh; } my $line1 = qr/'id','uuid','status','tags','entry','start','due','recur','end','project','priority','fg','bg','description'\n/; -my $line2 = qr/'.{8}-.{4}-.{4}-.{4}-.{12}','pending','',\d+,,,,,'A','H',,,'one'\n/; -my $line3 = qr/'.{8}-.{4}-.{4}-.{4}-.{12}','pending','tag1 tag2',\d+,,,,,,,,,'two'\n/; +my $line2 = qr/1,'.{8}-.{4}-.{4}-.{4}-.{12}','pending','',\d+,,,,,'A','H',,,'one'\n/; +my $line3 = qr/2,'.{8}-.{4}-.{4}-.{4}-.{12}','pending','tag1 tag2',\d+,,,,,,,,,'two'\n/; like ($lines[0], $line1, "export line one"); like ($lines[1], $line2, "export line two"); diff --git a/src/tests/undo.t b/src/tests/undo.t index 32131f21a..3776c2d9a 100755 --- a/src/tests/undo.t +++ b/src/tests/undo.t @@ -45,19 +45,19 @@ ok (-r 'pending.data', 'pending.data created'); like ($output, qr/Status\s+Pending\n/, 'Pending'); $output = qx{../task rc:undo.rc do 1; ../task rc:undo.rc info 1}; -ok (! -r 'completed.data', 'completed.data not created'); +ok (-r 'completed.data', 'completed.data created'); like ($output, qr/Status\s+Completed\n/, 'Completed'); $output = qx{../task rc:undo.rc undo 1; ../task rc:undo.rc info 1}; -ok (! -r 'completed.data', 'completed.data not created'); +ok (-r 'completed.data', 'completed.data created'); like ($output, qr/Status\s+Pending\n/, 'Pending'); $output = qx{../task rc:undo.rc do 1; ../task rc:undo.rc list}; -like ($output, qr/^No matches/, 'No matches'); +like ($output, qr/No matches/, 'No matches'); $output = qx{../task rc:undo.rc undo 1; ../task rc:undo.rc info 1}; like ($output, qr/Task 1 not found/, 'Task 1 not found'); -like ($output, qr/No matches/, 'No matches'); +like ($output, qr/Task 1 not found/, 'No matches'); # Cleanup. ok (-r 'pending.data', 'Need to remove pending.data');