reckon 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +54 -3
- data/Gemfile.lock +1 -1
- data/README.md +23 -19
- data/Rakefile +2 -2
- data/bin/build-new-version.sh +26 -0
- data/bin/reckon +4 -1
- data/lib/reckon.rb +1 -0
- data/lib/reckon/app.rb +13 -150
- data/lib/reckon/cosine_similarity.rb +67 -62
- data/lib/reckon/date_column.rb +3 -2
- data/lib/reckon/ledger_parser.rb +1 -1
- data/lib/reckon/money.rb +12 -5
- data/lib/reckon/options.rb +157 -0
- data/lib/reckon/version.rb +1 -1
- data/spec/cosine_training_and_test.rb +52 -0
- data/spec/integration/another_bank_example/output.ledger +3 -3
- data/spec/integration/ask_for_account/cli_input.exp +33 -0
- data/spec/integration/ask_for_account/expected_output +11 -0
- data/spec/integration/ask_for_account/input.csv +9 -0
- data/spec/integration/ask_for_account/test_args +1 -0
- data/spec/integration/broker_canada_example/output.ledger +2 -2
- data/spec/integration/chase/account_tokens_and_regex/output.ledger +3 -3
- data/spec/integration/chase/default_account_names/output.ledger +3 -3
- data/spec/integration/chase/learn_from_existing/output.ledger +3 -3
- data/spec/integration/chase/simple/output.ledger +3 -3
- data/spec/integration/danish_kroner_nordea_example/output.ledger +1 -1
- data/spec/integration/extratofake/output.ledger +1 -1
- data/spec/integration/harder_date_example/output.ledger +2 -2
- data/spec/integration/invalid_header_example/test_args +1 -1
- data/spec/integration/ledger_date_format/compare_cmds +1 -0
- data/spec/integration/ledger_date_format/input.csv +3 -0
- data/spec/integration/ledger_date_format/output.ledger +12 -0
- data/spec/integration/ledger_date_format/test_args +1 -0
- data/spec/integration/test.sh +78 -27
- data/spec/reckon/app_spec.rb +21 -19
- data/spec/reckon/csv_parser_spec.rb +3 -3
- data/spec/reckon/date_column_spec.rb +12 -0
- data/spec/reckon/money_spec.rb +3 -3
- data/spec/reckon/options_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf144e0683d1b618fbc046ade5af1c9fd37a69c2a62ee393301ce26f9b9a475
|
4
|
+
data.tar.gz: 32fc57d45adec068894497619c357a36482ede4e547a3169a4c8faf95e731a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5cdf653ec68d8360526c131335249fce69c9b51b12824023263621fb743c4c769cf9e9a44aa37108d8d1ef3ad51bba9b9268e36259c7d4597dddf20abf3c368
|
7
|
+
data.tar.gz: 0af870f477d800fb76edf3d7a4e31ef1120d40817b55d8e8da7175bad0e6daa2a981186e5bfc258a46703dd81cb1c07ed805a0260e9472264a5817fd207a9649
|
data/.github/workflows/ruby.yml
CHANGED
@@ -34,10 +34,10 @@ jobs:
|
|
34
34
|
- 2.3.7
|
35
35
|
steps:
|
36
36
|
- uses: actions/checkout@v2
|
37
|
+
- name: Update package
|
38
|
+
run: sudo apt-get update
|
37
39
|
- name: Install packages
|
38
|
-
run: sudo apt-get -y install ledger hledger
|
39
|
-
- name: Install bundler
|
40
|
-
run: sudo gem install -v 1.17.3 bundler
|
40
|
+
run: sudo apt-get -y install ledger hledger expect
|
41
41
|
- name: Set up Ruby
|
42
42
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
43
43
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
@@ -45,6 +45,6 @@ jobs:
|
|
45
45
|
# uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
46
46
|
with:
|
47
47
|
ruby-version: ${{ matrix.ruby-version }}
|
48
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems
|
48
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems
|
49
49
|
- name: Run tests
|
50
50
|
run: bundle exec rake test_all
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,59 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v0.8.0](https://github.com/cantino/reckon/tree/v0.8.0) (2021-08-08)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/cantino/reckon/compare/v0.
|
5
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.7.2...v0.8.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- --date-format '%d/%m/%Y' not working [\#113](https://github.com/cantino/reckon/issues/113)
|
10
|
+
- Reckon behaviour does not match what is explained on README.md [\#112](https://github.com/cantino/reckon/issues/112)
|
11
|
+
- --date-format '%d/%m/%Y' not working [\#111](https://github.com/cantino/reckon/issues/111)
|
12
|
+
- --date-format '%d/ [\#110](https://github.com/cantino/reckon/issues/110)
|
13
|
+
|
14
|
+
**Merged pull requests:**
|
15
|
+
|
16
|
+
- Add ledger-date-format option to specify ledger file date format [\#114](https://github.com/cantino/reckon/pull/114) ([benprew](https://github.com/benprew))
|
17
|
+
|
18
|
+
## [v0.7.2](https://github.com/cantino/reckon/tree/v0.7.2) (2021-04-22)
|
19
|
+
|
20
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.7.1...v0.7.2)
|
21
|
+
|
22
|
+
**Closed issues:**
|
23
|
+
|
24
|
+
- \[feature request\] Better format for large transactions [\#108](https://github.com/cantino/reckon/issues/108)
|
25
|
+
- cosine similarity not comparing documents correctly [\#106](https://github.com/cantino/reckon/issues/106)
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- Add thousands separator in money output. Fixes \#108. [\#109](https://github.com/cantino/reckon/pull/109) ([benprew](https://github.com/benprew))
|
30
|
+
- Cosine similarity should use all docs tokens. not just matched tokens. [\#107](https://github.com/cantino/reckon/pull/107) ([benprew](https://github.com/benprew))
|
31
|
+
- Test getting expect working with actions [\#105](https://github.com/cantino/reckon/pull/105) ([benprew](https://github.com/benprew))
|
32
|
+
|
33
|
+
## [v0.7.1](https://github.com/cantino/reckon/tree/v0.7.1) (2021-02-07)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.7.0...v0.7.1)
|
36
|
+
|
37
|
+
**Closed issues:**
|
38
|
+
|
39
|
+
- bug when asking for account name [\#103](https://github.com/cantino/reckon/issues/103)
|
40
|
+
|
41
|
+
## [v0.7.0](https://github.com/cantino/reckon/tree/v0.7.0) (2021-02-06)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.6.2...v0.7.0)
|
44
|
+
|
45
|
+
**Closed issues:**
|
46
|
+
|
47
|
+
- fail on unknown accounts [\#96](https://github.com/cantino/reckon/issues/96)
|
48
|
+
|
49
|
+
**Merged pull requests:**
|
50
|
+
|
51
|
+
- Fail on unknown account [\#102](https://github.com/cantino/reckon/pull/102) ([benprew](https://github.com/benprew))
|
52
|
+
- Joined split sentence to one [\#101](https://github.com/cantino/reckon/pull/101) ([RidaAyed](https://github.com/RidaAyed))
|
53
|
+
|
54
|
+
## [v0.6.2](https://github.com/cantino/reckon/tree/v0.6.2) (2021-01-25)
|
55
|
+
|
56
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.6.1...v0.6.2)
|
6
57
|
|
7
58
|
**Closed issues:**
|
8
59
|
|
@@ -171,6 +222,7 @@
|
|
171
222
|
- Unattended mode and custom tokens support [\#47](https://github.com/cantino/reckon/pull/47) ([vzctl](https://github.com/vzctl))
|
172
223
|
- \[RFC\] Implement issue \#40: Tab completion [\#46](https://github.com/cantino/reckon/pull/46) ([BlackEdder](https://github.com/BlackEdder))
|
173
224
|
- set readline to allow for backspace in ask dialog [\#44](https://github.com/cantino/reckon/pull/44) ([mrtazz](https://github.com/mrtazz))
|
225
|
+
- Fix --encoding option [\#41](https://github.com/cantino/reckon/pull/41) ([mamciek](https://github.com/mamciek))
|
174
226
|
|
175
227
|
## [v0.3.10](https://github.com/cantino/reckon/tree/v0.3.10) (2014-08-16)
|
176
228
|
|
@@ -191,7 +243,6 @@
|
|
191
243
|
|
192
244
|
**Merged pull requests:**
|
193
245
|
|
194
|
-
- Fix --encoding option [\#41](https://github.com/cantino/reckon/pull/41) ([mamciek](https://github.com/mamciek))
|
195
246
|
- Added spec for csv files from Broker Canada [\#36](https://github.com/cantino/reckon/pull/36) ([BlackEdder](https://github.com/BlackEdder))
|
196
247
|
- Date format [\#35](https://github.com/cantino/reckon/pull/35) ([BlackEdder](https://github.com/BlackEdder))
|
197
248
|
- Added example from a french bank [\#34](https://github.com/cantino/reckon/pull/34) ([BlackEdder](https://github.com/BlackEdder))
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -42,32 +42,37 @@ Learn more:
|
|
42
42
|
-o, --output-file FILE The ledger file to append to
|
43
43
|
-l, --learn-from FILE An existing ledger file to learn accounts from
|
44
44
|
--ignore-columns 1,2,5
|
45
|
-
Columns to ignore
|
45
|
+
Columns to ignore, starts from 1
|
46
46
|
--money-column 2
|
47
|
-
|
47
|
+
Column number of the money column, starts from 1
|
48
48
|
--raw-money
|
49
49
|
Don't format money column (for stocks)
|
50
50
|
--date-column 3
|
51
|
-
|
51
|
+
Column number of the date column, starts from 1
|
52
52
|
--contains-header [N]
|
53
|
-
|
53
|
+
Skip N header rows - default 1
|
54
54
|
--csv-separator ','
|
55
|
-
|
55
|
+
CSV separator (default ',')
|
56
56
|
--comma-separates-cents
|
57
|
-
Use comma
|
57
|
+
Use comma to separate cents ($100,50 vs. $100.50)
|
58
58
|
--encoding 'UTF-8'
|
59
|
-
Specify an encoding for the CSV file
|
60
|
-
-c, --currency '$' Currency symbol to use
|
61
|
-
--date-format
|
62
|
-
|
63
|
-
|
59
|
+
Specify an encoding for the CSV file
|
60
|
+
-c, --currency '$' Currency symbol to use - default $ (ex £, EUR)
|
61
|
+
--date-format FORMAT
|
62
|
+
CSV file date format (see `date` for format)
|
63
|
+
--ledger-date-format FORMAT
|
64
|
+
Ledger date format (see `date` for format)
|
65
|
+
-u, --unattended Don't ask questions and guess all the accounts automatically. Use with --learn-from or --account-tokens options.
|
64
66
|
-t, --account-tokens FILE YAML file with manually-assigned tokens for each account (see README)
|
67
|
+
--table-output-file FILE
|
65
68
|
--default-into-account NAME
|
66
69
|
Default into account
|
67
70
|
--default-outof-account NAME
|
68
71
|
Default 'out of' account
|
72
|
+
--fail-on-unknown-account
|
73
|
+
Fail on unmatched transactions.
|
69
74
|
--suffixed
|
70
|
-
|
75
|
+
Append currency symbol as a suffix.
|
71
76
|
-h, --help Show this message
|
72
77
|
--version Show version
|
73
78
|
|
@@ -78,13 +83,13 @@ If you find CSV files that it can't parse, send me examples or pull requests!
|
|
78
83
|
You can run reckon in a non-interactive mode.
|
79
84
|
To guess the accounts reckon can use an existing ledger file or a token file with keywords.
|
80
85
|
|
81
|
-
`reckon --unattended -l 2010.dat -f bank.csv -o ledger.dat`
|
86
|
+
`reckon --unattended -a Checking -l 2010.dat -f bank.csv -o ledger.dat`
|
82
87
|
|
83
|
-
`reckon --unattended --account-tokens tokens.yaml -f bank.csv -o ledger.dat`
|
88
|
+
`reckon --unattended -a Checking --account-tokens tokens.yaml -f bank.csv -o ledger.dat`
|
84
89
|
|
85
90
|
In unattended mode, you can use STDIN to read your csv data, by specifying `-` as the argument to `-f`.
|
86
91
|
|
87
|
-
`csv_file_generator | reckon --unattended -l 2010.dat -o ledger.dat -f -`
|
92
|
+
`csv_file_generator | reckon --unattended -a Checking -l 2010.dat -o ledger.dat -f -`
|
88
93
|
|
89
94
|
### Account Tokens
|
90
95
|
|
@@ -135,11 +140,10 @@ We encourage you to contribute to Reckon! Here is some information to help you.
|
|
135
140
|
|
136
141
|
1. Fork the project.
|
137
142
|
2. Make your feature addition or bug fix.
|
138
|
-
3. Add tests for it. This is important so I don't break it in a
|
139
|
-
4.
|
140
|
-
5. Commit, do not mess with rakefile, version, or history.
|
143
|
+
3. Add tests for it. This is important so I don't break it in a future version unintentionally.
|
144
|
+
4. Commit, do not mess with rakefile, version, or history.
|
141
145
|
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
142
|
-
|
146
|
+
5. Send me a pull request. Bonus points for topic branches.
|
143
147
|
|
144
148
|
### Integration Tests
|
145
149
|
|
data/Rakefile
CHANGED
@@ -17,6 +17,6 @@ task :test_all do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
task :integration_tests do
|
20
|
-
|
21
|
-
raise 'Integration tests failed'
|
20
|
+
cmd = 'prove -v ./spec/integration/test.sh'
|
21
|
+
raise 'Integration tests failed' unless system(cmd)
|
22
22
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
VERSION=$1
|
6
|
+
|
7
|
+
echo "Install github_changelog_generator"
|
8
|
+
# gem install --user github_changelog_generator
|
9
|
+
|
10
|
+
echo "Update 'lib/reckon/version.rb'"
|
11
|
+
echo -e "module Reckon\n VERSION=\"$VERSION\"\nend" > lib/reckon/version.rb
|
12
|
+
echo "Run `bundle install` to build updated Gemfile.lock"
|
13
|
+
bundle install
|
14
|
+
echo "Run changelog generator (requires $TOKEN to be your github token)"
|
15
|
+
github_changelog_generator -u cantino -p reckon -t $TOKEN --future-release v$VERSION
|
16
|
+
echo "Commit changes"
|
17
|
+
git add CHANGELOG.md lib/reckon/version.rb Gemfile.lock
|
18
|
+
git commit -m "Release $VERSION"
|
19
|
+
echo "Tag release"
|
20
|
+
git tag v$VERSION
|
21
|
+
echo "Build new gem"
|
22
|
+
gem build reckon.gemspec
|
23
|
+
echo "Push changes and tags"
|
24
|
+
echo "git push && git push --tags"
|
25
|
+
echo "Push new gem"
|
26
|
+
echo "gem push reckon-$VERSION.gem"
|
data/bin/reckon
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'reckon'
|
5
5
|
|
6
6
|
begin
|
7
|
-
options = Reckon::
|
7
|
+
options = Reckon::Options.parse
|
8
8
|
rescue RuntimeError => e
|
9
9
|
puts("ERROR: #{e}")
|
10
10
|
exit(1)
|
@@ -13,6 +13,9 @@ reckon = Reckon::App.new(options)
|
|
13
13
|
|
14
14
|
if options[:print_table]
|
15
15
|
reckon.output_table
|
16
|
+
if options[:table_output_file]
|
17
|
+
File.open(options[:table_output_file], 'w') { |fh| reckon.output_table fh }
|
18
|
+
end
|
16
19
|
exit
|
17
20
|
end
|
18
21
|
|
data/lib/reckon.rb
CHANGED
data/lib/reckon/app.rb
CHANGED
@@ -20,10 +20,10 @@ module Reckon
|
|
20
20
|
learn!
|
21
21
|
end
|
22
22
|
|
23
|
-
def interactive_output(str)
|
23
|
+
def interactive_output(str, fh = $stdout)
|
24
24
|
return if options[:unattended]
|
25
25
|
|
26
|
-
puts str
|
26
|
+
fh.puts str
|
27
27
|
end
|
28
28
|
|
29
29
|
def learn!
|
@@ -161,7 +161,7 @@ module Reckon
|
|
161
161
|
rows.sort_by { |n| [n[:date], -n[:money], n[:description]] }.each { |row| yield row }
|
162
162
|
end
|
163
163
|
|
164
|
-
def print_transaction(rows)
|
164
|
+
def print_transaction(rows, fh = $stdout)
|
165
165
|
str = "\n"
|
166
166
|
header = %w[Date Amount Description Note]
|
167
167
|
maxes = header.map(&:length)
|
@@ -185,7 +185,7 @@ module Reckon
|
|
185
185
|
str += "\n"
|
186
186
|
end
|
187
187
|
|
188
|
-
interactive_output str
|
188
|
+
interactive_output str, fh
|
189
189
|
end
|
190
190
|
|
191
191
|
def ask_account_question(msg, row)
|
@@ -193,11 +193,13 @@ module Reckon
|
|
193
193
|
LOGGER.info "possible_answers===> #{possible_answers.inspect}"
|
194
194
|
|
195
195
|
if options[:unattended]
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
196
|
+
if options[:fail_on_unknown_account] && possible_answers.empty?
|
197
|
+
raise %(Couldn't find any matches for '#{row[:description]}'
|
198
|
+
Try adding an account token with --account-tokens)
|
199
|
+
end
|
200
|
+
|
201
|
+
default = options[:default_outof_account]
|
202
|
+
default = options[:default_into_account] if row[:pretty_money][0] == '-'
|
201
203
|
return possible_answers[0] || default
|
202
204
|
end
|
203
205
|
|
@@ -278,151 +280,12 @@ module Reckon
|
|
278
280
|
exit
|
279
281
|
end
|
280
282
|
|
281
|
-
def output_table
|
283
|
+
def output_table(fh = $stdout)
|
282
284
|
rows = []
|
283
285
|
each_row_backwards do |row|
|
284
286
|
rows << row
|
285
287
|
end
|
286
|
-
print_transaction(rows)
|
287
|
-
end
|
288
|
-
|
289
|
-
def self.parse_opts(args=ARGV, stdin=STDIN)
|
290
|
-
options = { :output_file => STDOUT }
|
291
|
-
OptionParser.new do |opts|
|
292
|
-
opts.banner = "Usage: Reckon.rb [options]"
|
293
|
-
opts.separator ""
|
294
|
-
|
295
|
-
opts.on("-f", "--file FILE", "The CSV file to parse") do |file|
|
296
|
-
options[:file] = file
|
297
|
-
end
|
298
|
-
|
299
|
-
opts.on("-a", "--account NAME", "The Ledger Account this file is for") do |a|
|
300
|
-
options[:bank_account] = a
|
301
|
-
end
|
302
|
-
|
303
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
304
|
-
options[:verbose] = v
|
305
|
-
end
|
306
|
-
|
307
|
-
opts.on("-i", "--inverse", "Use the negative of each amount") do |v|
|
308
|
-
options[:inverse] = v
|
309
|
-
end
|
310
|
-
|
311
|
-
opts.on("-p", "--print-table", "Print out the parsed CSV in table form") do |p|
|
312
|
-
options[:print_table] = p
|
313
|
-
end
|
314
|
-
|
315
|
-
opts.on("-o", "--output-file FILE", "The ledger file to append to") do |o|
|
316
|
-
options[:output_file] = File.open(o, 'a')
|
317
|
-
end
|
318
|
-
|
319
|
-
opts.on("-l", "--learn-from FILE", "An existing ledger file to learn accounts from") do |l|
|
320
|
-
options[:existing_ledger_file] = l
|
321
|
-
end
|
322
|
-
|
323
|
-
opts.on("", "--ignore-columns 1,2,5", "Columns to ignore in the CSV file - the first column is column 1") do |ignore|
|
324
|
-
options[:ignore_columns] = ignore.split(",").map { |i| i.to_i }
|
325
|
-
end
|
326
|
-
|
327
|
-
opts.on("", "--money-column 2", Integer, "Specify the money column instead of letting Reckon guess - the first column is column 1") do |column_number|
|
328
|
-
options[:money_column] = column_number
|
329
|
-
end
|
330
|
-
|
331
|
-
opts.on("", "--raw-money", "Don't format money column (for stocks)") do |n|
|
332
|
-
options[:raw] = n
|
333
|
-
end
|
334
|
-
|
335
|
-
opts.on("", "--date-column 3", Integer, "Specify the date column instead of letting Reckon guess - the first column is column 1") do |column_number|
|
336
|
-
options[:date_column] = column_number
|
337
|
-
end
|
338
|
-
|
339
|
-
opts.on("", "--contains-header [N]", "The first row of the CSV is a header and should be skipped. Optionally add the number of rows to skip.") do |contains_header|
|
340
|
-
options[:contains_header] = 1
|
341
|
-
options[:contains_header] = contains_header.to_i if contains_header
|
342
|
-
end
|
343
|
-
|
344
|
-
opts.on("", "--csv-separator ','", "Separator for parsing the CSV - default is comma.") do |csv_separator|
|
345
|
-
options[:csv_separator] = csv_separator
|
346
|
-
end
|
347
|
-
|
348
|
-
opts.on("", "--comma-separates-cents", "Use comma instead of period to deliminate dollars from cents when parsing ($100,50 instead of $100.50)") do |c|
|
349
|
-
options[:comma_separates_cents] = c
|
350
|
-
end
|
351
|
-
|
352
|
-
opts.on("", "--encoding 'UTF-8'", "Specify an encoding for the CSV file; not usually needed") do |e|
|
353
|
-
options[:encoding] = e
|
354
|
-
end
|
355
|
-
|
356
|
-
opts.on("-c", "--currency '$'", "Currency symbol to use, defaults to $ (£, EUR)") do |e|
|
357
|
-
options[:currency] = e
|
358
|
-
end
|
359
|
-
|
360
|
-
opts.on("", "--date-format '%d/%m/%Y'", "Force the date format (see Ruby DateTime strftime)") do |d|
|
361
|
-
options[:date_format] = d
|
362
|
-
end
|
363
|
-
|
364
|
-
opts.on("-u", "--unattended", "Don't ask questions and guess all the accounts automatically. Used with --learn-from or --account-tokens options.") do |n|
|
365
|
-
options[:unattended] = n
|
366
|
-
end
|
367
|
-
|
368
|
-
opts.on("-t", "--account-tokens FILE", "YAML file with manually-assigned tokens for each account (see README)") do |a|
|
369
|
-
options[:account_tokens_file] = a
|
370
|
-
end
|
371
|
-
|
372
|
-
opts.on("", "--default-into-account NAME", "Default into account") do |a|
|
373
|
-
options[:default_into_account] = a
|
374
|
-
end
|
375
|
-
|
376
|
-
opts.on("", "--default-outof-account NAME", "Default 'out of' account") do |a|
|
377
|
-
options[:default_outof_account] = a
|
378
|
-
end
|
379
|
-
|
380
|
-
opts.on("", "--suffixed", "If --currency should be used as a suffix. Defaults to false.") do |e|
|
381
|
-
options[:suffixed] = e
|
382
|
-
end
|
383
|
-
|
384
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
385
|
-
puts opts
|
386
|
-
exit
|
387
|
-
end
|
388
|
-
|
389
|
-
opts.on_tail("--version", "Show version") do
|
390
|
-
puts VERSION
|
391
|
-
exit
|
392
|
-
end
|
393
|
-
|
394
|
-
opts.parse!(args)
|
395
|
-
end
|
396
|
-
|
397
|
-
if options[:file] == '-'
|
398
|
-
unless options[:unattended]
|
399
|
-
raise "--unattended is required to use STDIN as CSV source."
|
400
|
-
end
|
401
|
-
|
402
|
-
puts "Reading csv from STDIN"
|
403
|
-
options[:string] = stdin.read
|
404
|
-
end
|
405
|
-
|
406
|
-
unless options[:file]
|
407
|
-
options[:file] = @@cli.ask("What CSV file should I parse? ")
|
408
|
-
unless options[:file].length > 0
|
409
|
-
puts "\nYou must provide a CSV file to parse.\n"
|
410
|
-
puts parser
|
411
|
-
exit
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
unless options[:bank_account]
|
416
|
-
fail "Please specify --account in unattended mode" if options[:unattended]
|
417
|
-
|
418
|
-
options[:bank_account] = @@cli.ask("What is the account name of this bank account in Ledger? ") do |q|
|
419
|
-
q.readline = true
|
420
|
-
q.validate = /^.{2,}$/
|
421
|
-
q.default = "Assets:Bank:Checking"
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
options
|
288
|
+
print_transaction(rows, fh)
|
426
289
|
end
|
427
290
|
end
|
428
291
|
end
|