mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - .taskrc timestamp
- Added a "created by ..." entry with timestamp inside the generated .taskrc file.
This commit is contained in:
parent
fa195a3cb2
commit
409c6ee9b9
1 changed files with 13 additions and 4 deletions
|
@ -34,10 +34,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "Directory.h"
|
||||
#include "Date.h"
|
||||
#include "File.h"
|
||||
#include "Config.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "../auto.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This string is used in two ways:
|
||||
|
@ -395,12 +397,19 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
|||
std::string::size_type loc = defaults.find ("data.location=~/.task");
|
||||
// loc+0^ +14^ +21^
|
||||
|
||||
std::string contents = defaults.substr (0, loc + 14) +
|
||||
data +
|
||||
defaults.substr (loc + 21, std::string::npos);
|
||||
Date now;
|
||||
std::stringstream contents;
|
||||
contents << "# [Created by "
|
||||
<< PACKAGE_STRING
|
||||
<< " "
|
||||
<< now.toStringWithTime ()
|
||||
<< "]\n"
|
||||
<< defaults.substr (0, loc + 14)
|
||||
<< data
|
||||
<< defaults.substr (loc + 21);
|
||||
|
||||
// Write out the new file.
|
||||
if (! File::write (rc, contents))
|
||||
if (! File::write (rc, contents.str ()))
|
||||
throw std::string ("Could not write to '") + rc + "'";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue