[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-docs] branch master updated: Add Emacs Lisp command ‘TDM-recursiv
From: |
gnunet |
Subject: |
[taler-docs] branch master updated: Add Emacs Lisp command ‘TDM-recursive-help’ |
Date: |
Tue, 18 Jan 2022 11:05:14 +0100 |
This is an automated email from the git hooks/post-receive script.
ttn pushed a commit to branch master
in repository docs.
The following commit(s) were added to refs/heads/master by this push:
new 48051ad Add Emacs Lisp command ‘TDM-recursive-help’
48051ad is described below
commit 48051ad829dbfba2c58c19eb67f2622fbd2357a6
Author: Thien-Thi Nguyen <ttn@gnuvola.org>
AuthorDate: Tue Jan 18 05:04:35 2022 -0500
Add Emacs Lisp command ‘TDM-recursive-help’
* manpages/TDM.el (TDM-recursive-help): New command.
---
manpages/TDM.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/manpages/TDM.el b/manpages/TDM.el
index b4fabc7..a58fb1c 100644
--- a/manpages/TDM.el
+++ b/manpages/TDM.el
@@ -1,6 +1,6 @@
;;; TDM.el --- editing Taler docs.git/manpages/* -*- lexical-binding: t -*-
-;; Copyright (C) 2021 Taler Systems SA
+;; Copyright (C) 2021, 2022 Taler Systems SA
;;
;; This file is part of GNU TALER.
;;
@@ -22,7 +22,10 @@
;;; Commentary:
-;; This library currently provides one command: ‘TDM-convert-options’.
+;; This library currently provides two commands: ‘TDM-convert-options’
+;; and ‘TDM-recursive-help’.
+;;
+;; * ‘TDM-convert-options’
;; The intended workflow is simple:
;; - Create a new file from template.
;; - Do the <FOO> substitutions / deletions as necessary.
@@ -49,6 +52,15 @@
;; There are a couple TODO items, which point to situations that
;; have not yet arisen in practice, but that might theoretically
;; bother us in the future.
+;;
+;; * ‘TDM-recursive-help’
+;; This command is intended for libeufin programs, specifically
+;; libeufin-sandbox, libeufin-nexus, and libeufin-cli. However,
+;; it should work with any Java program that uses clikt, or any
+;; Python program that uses click, for its command-line handling.
+;;
+;; You can obtain the --help output (recursively) in a buffer
+;; and write it to a file for further analysis / processing.
;;; Code:
@@ -121,6 +133,40 @@ Prefix arg KEEP-ORIG means don't delete them."
(save-excursion
(delete-region p q)))))
+(defun TDM-recursive-help (command)
+ "Call COMMAND --help and recurse on its subcommands.
+Subcommands are identified by \"Commands:\" in column 0
+in the output.
+
+Collect the output in a new buffer *COMMAND --help*,
+with one page per --help output."
+ (interactive "sCommand: ")
+ (let ((out (get-buffer-create (format "*%s --help*" command))))
+ (with-current-buffer out
+ (erase-buffer))
+ (cl-labels
+ ;; visit command
+ ((v (c) (with-temp-buffer
+ (apply #'call-process (car c) nil t nil
+ (append (cdr c) (list "--help")))
+ (goto-char (point-min))
+ (when (re-search-forward "^Commands:\n" nil t)
+ (while (looking-at "[ ][ ]\\(\\S +\\)")
+ (let ((sub (match-string 1)))
+ (v (append c (list sub))))
+ (forward-line 1)
+ (while (looking-at "[ ][ ][ ]")
+ (forward-line 1))))
+ (let ((s (buffer-string)))
+ (message "c: %s" c)
+ (with-current-buffer out
+ (goto-char (point-min))
+ (insert "\f\n")
+ (insert "$ " (substring (format "%s" c) 1 -1) "\n")
+ (insert s "\n"))))))
+ (v (list command)))
+ (switch-to-buffer out)))
+
(provide 'TDM)
;;; TDM.el ends here
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-docs] branch master updated: Add Emacs Lisp command ‘TDM-recursive-help’,
gnunet <=