*** empty log message ***
This commit is contained in:
parent
f42d76f85f
commit
c3c401ac0f
2 changed files with 58 additions and 23 deletions
35
main.cc
35
main.cc
|
|
@ -160,9 +160,8 @@ int parse_and_report(config_t& config, report_t& report,
|
|||
|
||||
std::string first_arg;
|
||||
if (command == "w") {
|
||||
if (arg == args.end())
|
||||
throw new error("The 'output' command requires a file argument");
|
||||
first_arg = *arg++;
|
||||
if (arg != args.end())
|
||||
first_arg = *arg++;
|
||||
}
|
||||
else if (command == "W") {
|
||||
if (report.output_file.empty())
|
||||
|
|
@ -184,6 +183,36 @@ int parse_and_report(config_t& config, report_t& report,
|
|||
|
||||
std::auto_ptr<entry_t> new_entry;
|
||||
if (command == "e") {
|
||||
if (arg == args.end()) {
|
||||
std::cout << "\
|
||||
The entry command requires at least one argument, so Ledger can intelligently\n\
|
||||
create a new entry for you. The possible arguments are:\n\
|
||||
DATE PAYEE [ACCOUNT] [AMOUNT] [DRAW ACCOUNT]\n\n\
|
||||
Some things to note:\n\
|
||||
- The ACCOUNT is optional; if no account is given, the last account affected\n\
|
||||
by PAYEE is used. If no payee can be found, the generic account 'Expenses'\n\
|
||||
is used.\n\
|
||||
- The AMOUNT is optional; if not specified, the same amount is used as the\n\
|
||||
last time PAYEE was seen, or 0 if not applicable.\n\
|
||||
- The AMOUNT does not require a commodity; if none is given, the commodity\n\
|
||||
currently contained within ACCOUNT is used, or no commodity at all if\n\
|
||||
either: the ACCOUNT was not found, or it contains more than one commodity.\n\
|
||||
- Lastly, the DRAW ACCOUNT is optional; if not present, the last account\n\
|
||||
drawn from by PAYEE is used, or the 'basket' account (specified with\n\
|
||||
'A ACCOUNT' in your Ledger file) if that does not apply, or the generic\n\
|
||||
account 'Equity' is used.\n\n\
|
||||
Here are a few examples, all of which may be equivalent depending on your\n\
|
||||
Ledger data:\n\
|
||||
ledger entry 3/25 chevron\n\
|
||||
ledger entry 3/25 chevron 20\n\
|
||||
ledger entry 3/25 chevron \\$20\n\
|
||||
ledger entry 3/25 chevron gas 20\n\
|
||||
ledger entry 3/25 chevron gas \\$20 checking\n\n\
|
||||
A final note: Ledger never modifies your data! You are responsible for\n\
|
||||
appending the output of this command to your Ledger file if you so choose."
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
new_entry.reset(derive_new_entry(*journal, arg, args.end()));
|
||||
if (! new_entry.get())
|
||||
return 1;
|
||||
|
|
|
|||
46
textual.cc
46
textual.cc
|
|
@ -882,32 +882,38 @@ void write_textual_journal(journal_t& journal, std::string path,
|
|||
unsigned long index = 0;
|
||||
std::string found;
|
||||
|
||||
if (path.empty()) {
|
||||
if (! journal.sources.empty())
|
||||
found = *journal.sources.begin();
|
||||
} else {
|
||||
#ifdef HAVE_REALPATH
|
||||
char buf1[PATH_MAX];
|
||||
char buf2[PATH_MAX];
|
||||
char buf1[PATH_MAX];
|
||||
char buf2[PATH_MAX];
|
||||
|
||||
::realpath(path.c_str(), buf1);
|
||||
for (strings_list::iterator i = journal.sources.begin();
|
||||
i != journal.sources.end();
|
||||
i++) {
|
||||
::realpath((*i).c_str(), buf2);
|
||||
if (std::strcmp(buf1, buf2) == 0) {
|
||||
found = *i;
|
||||
break;
|
||||
::realpath(path.c_str(), buf1);
|
||||
|
||||
for (strings_list::iterator i = journal.sources.begin();
|
||||
i != journal.sources.end();
|
||||
i++) {
|
||||
::realpath((*i).c_str(), buf2);
|
||||
if (std::strcmp(buf1, buf2) == 0) {
|
||||
found = *i;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
#else
|
||||
for (strings_list::iterator i = journal.sources.begin();
|
||||
i != journal.sources.end();
|
||||
i++) {
|
||||
if (path == *i) {
|
||||
found = *i;
|
||||
break;
|
||||
for (strings_list::iterator i = journal.sources.begin();
|
||||
i != journal.sources.end();
|
||||
i++) {
|
||||
if (path == *i) {
|
||||
found = *i;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (found.empty())
|
||||
throw new error(std::string("Journal does not refer to file '") +
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue