From 6dd4546253f298d234889df5591e3a6839e8ca47 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Thu, 21 Sep 2023 00:24:18 +0200 Subject: [PATCH 1/2] Support for markdown output in help messages This functionality can be used to provide on-line versions of the help messages for alire.ada.dev. It goes with https://github.com/alire-project/clic/pull/29 --- deps/clic | 2 +- src/alr/alr-commands.adb | 15 ++++++++++++++- src/alr/alr-commands.ads | 11 ++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/deps/clic b/deps/clic index 6879b9087..5c936c1e6 160000 --- a/deps/clic +++ b/deps/clic @@ -1 +1 @@ -Subproject commit 6879b90876a1c918b4e112f59c6db0e25b713f52 +Subproject commit 5c936c1e65ec4f6ba5428433a36d9cb3ee06764d diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index 62facdfda..9f54f86b9 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -79,6 +79,9 @@ package body Alr.Commands is No_TTY : aliased Boolean := False; -- Used to disable control characters in output + Markdown_Help : aliased Boolean := False; + -- Used to enable help display in markdown format + Version_Only : aliased Boolean := False; -- Just display the current version and exit @@ -157,6 +160,12 @@ package body Alr.Commands is Long_Switch => "--no-tty", Help => "Disables control characters in output"); + Define_Switch (Config, + Markdown_Help'Access, + Long_Switch => "--markdown", + Help => + "Enables output of markdown format for help"); + Define_Switch (Config, Prefer_Oldest'Access, Long_Switch => "--prefer-oldest", @@ -452,7 +461,11 @@ package body Alr.Commands is end if; if No_TTY then - CLIC.TTY.Force_Disable_TTY; + CLIC.Formatter.Force_Disable_TTY; + end if; + + if Markdown_Help then + CLIC.Formatter.Enable_Markdown; end if; -- Use CLIC.TTY selection/detection of TTY diff --git a/src/alr/alr-commands.ads b/src/alr/alr-commands.ads index 0857684ad..e141d9426 100644 --- a/src/alr/alr-commands.ads +++ b/src/alr/alr-commands.ads @@ -6,6 +6,7 @@ with Alire.Solver; with Alire.Version; with CLIC.Subcommand; +with CLIC.Formatter; private with GNAT.IO; private with CLIC.Subcommand.Instance; @@ -143,11 +144,11 @@ private Put_Error => Put_Error, Error_Exit => OS_Lib.Bailout, Set_Global_Switches => Set_Global_Switches, - TTY_Chapter => Alire.TTY.Bold, - TTY_Description => Alire.TTY.Description, - TTY_Version => Alire.TTY.Version, - TTY_Underline => Alire.TTY.Underline, - TTY_Emph => Alire.TTY.Emph); + TTY_Chapter => CLIC.Formatter.Chapter, + TTY_Description => CLIC.Formatter.Description, + TTY_Version => CLIC.Formatter.Version, + TTY_Underline => CLIC.Formatter.Underline, + TTY_Emph => CLIC.Formatter.Emph); Unset : constant String := "unset"; -- Canary for when a string switch is given without value From fb4c9d1b5743ea21fb5be45bd4a0897a5a216134 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Thu, 21 Sep 2023 20:22:23 +0200 Subject: [PATCH 2/2] Fix pin for "Support for markdown output in help messages" Fix failed check due to pin in alire.toml --- alire.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alire.toml b/alire.toml index 0647d91cc..2533042c7 100644 --- a/alire.toml +++ b/alire.toml @@ -49,7 +49,7 @@ windows = { ALIRE_OS = "windows" } [[pins]] aaa = { url = "https://github.com/mosteo/aaa", commit = "ecc38772bd4a6b469b54c62363766ea1c0e9f912" } ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" } -clic = { url = "https://github.com/alire-project/clic", commit = "6879b90876a1c918b4e112f59c6db0e25b713f52" } +clic = { url = "https://github.com/alire-project/clic", commit = "5c936c1e65ec4f6ba5428433a36d9cb3ee06764d" } dirty_booleans = { url = "https://github.com/mosteo/dirty_booleans", branch = "main" } diskflags = { url = "https://github.com/mosteo/diskflags", branch = "main" } gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "4e663b87a028252e7e074f054f8f453661397166" }