Add support of --version command line switch.

This commit is contained in:
Vadim Godunko
2024-10-04 13:31:55 +04:00
parent 99c065f461
commit 46122d7ff2
2 changed files with 47 additions and 0 deletions

View File

@@ -21,9 +21,13 @@ with VSS.Strings.Conversions;
with GNATdoc.Comments.Options;
with GNATdoc.Options;
with GNATdoc.Version;
with GPR2.Options;
with GPR2.Project.Registry.Exchange;
with VSS.Strings.Formatters;
with VSS.Strings.Formatters.Strings;
with VSS.Strings.Templates;
package body GNATdoc.Command_Line is
@@ -32,6 +36,11 @@ package body GNATdoc.Command_Line is
Long_Name => "help",
Description => "Display help information");
Version_Option : constant VSS.Command_Line.Binary_Option :=
(Short_Name => <>,
Long_Name => "version",
Description => "Display version");
Backend_Option : constant VSS.Command_Line.Value_Option :=
(Short_Name => <>,
Long_Name => "backend",
@@ -121,6 +130,7 @@ package body GNATdoc.Command_Line is
procedure Initialize is
begin
Parser.Add_Option (Help_Option);
Parser.Add_Option (Version_Option);
Parser.Add_Option (Print_Gpr_Registry_Option);
Parser.Add_Option (Style_Option);
Parser.Add_Option (Backend_Option);
@@ -173,6 +183,20 @@ package body GNATdoc.Command_Line is
VSS.Command_Line.Report_Message (Parser.Help_Text);
end if;
if Parser.Is_Specified (Version_Option) then
declare
Template : constant
VSS.Strings.Templates.Virtual_String_Template :=
"GNATdoc {}";
begin
VSS.Command_Line.Report_Error
(Template.Format
(VSS.Strings.Formatters.Strings.Image
(GNATdoc.Version.Version_String)));
end;
end if;
-- Process `--print-gpr-registry` if specified
if Parser.Is_Specified (Print_Gpr_Registry_Option) then

View File

@@ -0,0 +1,23 @@
------------------------------------------------------------------------------
-- GNAT Documentation Generation Tool --
-- --
-- Copyright (C) 2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
package GNATdoc.Version is
Version_String : VSS.Strings.Virtual_String :=
"%VERSION% (%DATE%)";
end GNATdoc.Version;