mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gnucash-cli] --report show/list outputs to stdout
and their error messages output to stderr
This commit is contained in:
parent
e5a14b8946
commit
51d00fcbe5
@ -214,8 +214,9 @@ scm_report_show (void *data,
|
||||
scm_c_use_module ("gnucash reports");
|
||||
gnc_report_init ();
|
||||
|
||||
scm_call_1 (scm_c_eval_string ("gnc:cmdline-report-show"),
|
||||
scm_from_utf8_string (args->show_report.c_str()));
|
||||
scm_call_2 (scm_c_eval_string ("gnc:cmdline-report-show"),
|
||||
scm_from_utf8_string (args->show_report.c_str ()),
|
||||
scm_current_output_port ());
|
||||
gnc_shutdown (0);
|
||||
return;
|
||||
}
|
||||
@ -230,7 +231,8 @@ scm_report_list ([[maybe_unused]] void *data,
|
||||
scm_c_use_module ("gnucash reports");
|
||||
gnc_report_init ();
|
||||
|
||||
scm_call_0 (scm_c_eval_string ("gnc:cmdline-report-list"));
|
||||
scm_call_1 (scm_c_eval_string ("gnc:cmdline-report-list"),
|
||||
scm_current_output_port ());
|
||||
gnc_shutdown (0);
|
||||
return;
|
||||
}
|
||||
|
@ -805,31 +805,31 @@ not found.")))
|
||||
(lambda (k v p) (if (equal? (gnc:report-template-name v) report) (cons v p) p))
|
||||
'() *gnc:_report-templates_*)))
|
||||
|
||||
(define-public (gnc:cmdline-report-list)
|
||||
(define-public (gnc:cmdline-report-list port)
|
||||
(for-each
|
||||
(lambda (template)
|
||||
(stderr-log "* ~a ~a\n"
|
||||
(if (gnc:report-template-parent-type template) "C" " ")
|
||||
(gnc:report-template-name template)))
|
||||
(format port "* ~a ~a\n"
|
||||
(if (gnc:report-template-parent-type template) "C" " ")
|
||||
(gnc:report-template-name template)))
|
||||
(sort (hash-fold
|
||||
(lambda (k v p) (if (gnc:report-template-in-menu? v) (cons v p) p))
|
||||
'() *gnc:_report-templates_*)
|
||||
(lambda (a b)
|
||||
(string<? (gnc:report-template-name a) (gnc:report-template-name b))))))
|
||||
|
||||
(define-public (gnc:cmdline-report-show report)
|
||||
(define-public (gnc:cmdline-report-show report port)
|
||||
(let ((templates (reportname->templates report)))
|
||||
(cond
|
||||
((null? templates)
|
||||
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
||||
(gnc:cmdline-report-list))
|
||||
(gnc:cmdline-report-list (current-error-port)))
|
||||
(else
|
||||
(for-each
|
||||
(lambda (template)
|
||||
(let* ((options-gen (gnc:report-template-options-generator template)))
|
||||
(stderr-log "\n* guid: ~a\n~a"
|
||||
(gnc:report-template-report-guid template)
|
||||
(gnc:html-render-options-changed (options-gen) #t))))
|
||||
(format port "\n* guid: ~a\n~a"
|
||||
(gnc:report-template-report-guid template)
|
||||
(gnc:html-render-options-changed (options-gen) #t))))
|
||||
templates)))))
|
||||
|
||||
(define-public (gnc:cmdline-run-report report export-type output-file dry-run?)
|
||||
@ -845,12 +845,12 @@ not found.")))
|
||||
(cond
|
||||
((null? templates)
|
||||
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
||||
(gnc:cmdline-report-list)
|
||||
(gnc:cmdline-report-list (current-error-port))
|
||||
(stderr-log "\n"))
|
||||
|
||||
((pair? (cdr templates))
|
||||
(stderr-log "~s matches multiple reports. Select guid instead:\n" report)
|
||||
(gnc:cmdline-report-show report)
|
||||
(gnc:cmdline-report-show report (current-error-port))
|
||||
(stderr-log "\n"))
|
||||
|
||||
(export-type (template-export report (car templates)
|
||||
|
Loading…
Reference in New Issue
Block a user