*** empty log message ***
This commit is contained in:
parent
f42d76f85f
commit
c3c401ac0f
2 changed files with 58 additions and 23 deletions
33
main.cc
33
main.cc
|
|
@ -160,8 +160,7 @@ int parse_and_report(config_t& config, report_t& report,
|
||||||
|
|
||||||
std::string first_arg;
|
std::string first_arg;
|
||||||
if (command == "w") {
|
if (command == "w") {
|
||||||
if (arg == args.end())
|
if (arg != args.end())
|
||||||
throw new error("The 'output' command requires a file argument");
|
|
||||||
first_arg = *arg++;
|
first_arg = *arg++;
|
||||||
}
|
}
|
||||||
else if (command == "W") {
|
else if (command == "W") {
|
||||||
|
|
@ -184,6 +183,36 @@ int parse_and_report(config_t& config, report_t& report,
|
||||||
|
|
||||||
std::auto_ptr<entry_t> new_entry;
|
std::auto_ptr<entry_t> new_entry;
|
||||||
if (command == "e") {
|
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()));
|
new_entry.reset(derive_new_entry(*journal, arg, args.end()));
|
||||||
if (! new_entry.get())
|
if (! new_entry.get())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -882,11 +882,16 @@ void write_textual_journal(journal_t& journal, std::string path,
|
||||||
unsigned long index = 0;
|
unsigned long index = 0;
|
||||||
std::string found;
|
std::string found;
|
||||||
|
|
||||||
|
if (path.empty()) {
|
||||||
|
if (! journal.sources.empty())
|
||||||
|
found = *journal.sources.begin();
|
||||||
|
} else {
|
||||||
#ifdef HAVE_REALPATH
|
#ifdef HAVE_REALPATH
|
||||||
char buf1[PATH_MAX];
|
char buf1[PATH_MAX];
|
||||||
char buf2[PATH_MAX];
|
char buf2[PATH_MAX];
|
||||||
|
|
||||||
::realpath(path.c_str(), buf1);
|
::realpath(path.c_str(), buf1);
|
||||||
|
|
||||||
for (strings_list::iterator i = journal.sources.begin();
|
for (strings_list::iterator i = journal.sources.begin();
|
||||||
i != journal.sources.end();
|
i != journal.sources.end();
|
||||||
i++) {
|
i++) {
|
||||||
|
|
@ -908,6 +913,7 @@ void write_textual_journal(journal_t& journal, std::string path,
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (found.empty())
|
if (found.empty())
|
||||||
throw new error(std::string("Journal does not refer to file '") +
|
throw new error(std::string("Journal does not refer to file '") +
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue