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");
|
scm_c_use_module ("gnucash reports");
|
||||||
gnc_report_init ();
|
gnc_report_init ();
|
||||||
|
|
||||||
scm_call_1 (scm_c_eval_string ("gnc:cmdline-report-show"),
|
scm_call_2 (scm_c_eval_string ("gnc:cmdline-report-show"),
|
||||||
scm_from_utf8_string (args->show_report.c_str()));
|
scm_from_utf8_string (args->show_report.c_str ()),
|
||||||
|
scm_current_output_port ());
|
||||||
gnc_shutdown (0);
|
gnc_shutdown (0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,7 +231,8 @@ scm_report_list ([[maybe_unused]] void *data,
|
|||||||
scm_c_use_module ("gnucash reports");
|
scm_c_use_module ("gnucash reports");
|
||||||
gnc_report_init ();
|
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);
|
gnc_shutdown (0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -805,31 +805,31 @@ not found.")))
|
|||||||
(lambda (k v p) (if (equal? (gnc:report-template-name v) report) (cons v p) p))
|
(lambda (k v p) (if (equal? (gnc:report-template-name v) report) (cons v p) p))
|
||||||
'() *gnc:_report-templates_*)))
|
'() *gnc:_report-templates_*)))
|
||||||
|
|
||||||
(define-public (gnc:cmdline-report-list)
|
(define-public (gnc:cmdline-report-list port)
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (template)
|
(lambda (template)
|
||||||
(stderr-log "* ~a ~a\n"
|
(format port "* ~a ~a\n"
|
||||||
(if (gnc:report-template-parent-type template) "C" " ")
|
(if (gnc:report-template-parent-type template) "C" " ")
|
||||||
(gnc:report-template-name template)))
|
(gnc:report-template-name template)))
|
||||||
(sort (hash-fold
|
(sort (hash-fold
|
||||||
(lambda (k v p) (if (gnc:report-template-in-menu? v) (cons v p) p))
|
(lambda (k v p) (if (gnc:report-template-in-menu? v) (cons v p) p))
|
||||||
'() *gnc:_report-templates_*)
|
'() *gnc:_report-templates_*)
|
||||||
(lambda (a b)
|
(lambda (a b)
|
||||||
(string<? (gnc:report-template-name a) (gnc:report-template-name 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)))
|
(let ((templates (reportname->templates report)))
|
||||||
(cond
|
(cond
|
||||||
((null? templates)
|
((null? templates)
|
||||||
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
||||||
(gnc:cmdline-report-list))
|
(gnc:cmdline-report-list (current-error-port)))
|
||||||
(else
|
(else
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (template)
|
(lambda (template)
|
||||||
(let* ((options-gen (gnc:report-template-options-generator template)))
|
(let* ((options-gen (gnc:report-template-options-generator template)))
|
||||||
(stderr-log "\n* guid: ~a\n~a"
|
(format port "\n* guid: ~a\n~a"
|
||||||
(gnc:report-template-report-guid template)
|
(gnc:report-template-report-guid template)
|
||||||
(gnc:html-render-options-changed (options-gen) #t))))
|
(gnc:html-render-options-changed (options-gen) #t))))
|
||||||
templates)))))
|
templates)))))
|
||||||
|
|
||||||
(define-public (gnc:cmdline-run-report report export-type output-file dry-run?)
|
(define-public (gnc:cmdline-run-report report export-type output-file dry-run?)
|
||||||
@ -845,12 +845,12 @@ not found.")))
|
|||||||
(cond
|
(cond
|
||||||
((null? templates)
|
((null? templates)
|
||||||
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
(stderr-log "Cannot find ~s. Valid reports:\n" report)
|
||||||
(gnc:cmdline-report-list)
|
(gnc:cmdline-report-list (current-error-port))
|
||||||
(stderr-log "\n"))
|
(stderr-log "\n"))
|
||||||
|
|
||||||
((pair? (cdr templates))
|
((pair? (cdr templates))
|
||||||
(stderr-log "~s matches multiple reports. Select guid instead:\n" report)
|
(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"))
|
(stderr-log "\n"))
|
||||||
|
|
||||||
(export-type (template-export report (car templates)
|
(export-type (template-export report (car templates)
|
||||||
|
Loading…
Reference in New Issue
Block a user