Skip to content

Commit 70a8d4f

Browse files
committed
Merge branch 'mr/thevenoux-langkit-query-language#564' into 'master'
Fix the `-V/--verbose` switches output Closes #564 See merge request eng/libadalang/langkit-query-language!559
2 parents 547bdb8 + db69780 commit 70a8d4f

File tree

14 files changed

+47
-51
lines changed

14 files changed

+47
-51
lines changed

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The following switches control the general ``gnatcheck`` behavior
1616
.. index:: --version
1717

1818

19-
``--version``
19+
``-V, --version``
2020
Display Copyright and version, then exit disregarding all other options.
2121

2222
.. index:: --help
@@ -395,7 +395,7 @@ GNATcheck:
395395
There are several command-line switches that you cannot pass through the
396396
``Switches`` attribute:
397397

398-
* ``--version``
398+
* ``-V, --version``
399399
* ``-h, --help``
400400
* ``--list-rules``
401401
* ``-P``

lkql_checker/src/gnatcheck-options.ads

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ package Gnatcheck.Options is
218218
(Parser => Parser,
219219
Name => "Version",
220220
Long => "--version",
221+
Short => "-V",
221222
Help => "show the tool version and exit");
222223

223224
package Help is new

lkql_checker/src/gnatcheck-output.adb

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ with GNAT.Directory_Operations; use GNAT.Directory_Operations;
1313
with GNAT.OS_Lib; use GNAT.OS_Lib;
1414
with GNAT.Traceback.Symbolic;
1515

16-
with Gnatcheck.Options; use Gnatcheck.Options;
17-
with Gnatcheck.String_Utilities; use Gnatcheck.String_Utilities;
16+
with Gnatcheck.Options; use Gnatcheck.Options;
1817

1918
with Interfaces.C_Streams; use Interfaces.C_Streams;
2019

@@ -250,39 +249,15 @@ package body Gnatcheck.Output is
250249
Emit_Message (Message, New_Line => New_Line, Log_Message => Log_Message);
251250
end Print;
252251

253-
------------------------
254-
-- Print_Tool_Version --
255-
------------------------
256-
257-
procedure Print_Tool_Version (Released_At : Positive) is
258-
begin
259-
if Gnatkp_Mode then
260-
Put_Line ("GNATKP " & Date);
261-
else
262-
Put_Line ("GNATCHECK " & Version_String);
263-
end if;
264-
265-
Put_Line
266-
("Copyright (C) "
267-
& Image (Released_At)
268-
& '-'
269-
& Current_Year
270-
& ", AdaCore.");
271-
end Print_Tool_Version;
272-
273252
------------------------
274253
-- Print_Version_Info --
275254
------------------------
276255

277-
procedure Print_Version_Info (Released_At : Positive) is
256+
procedure Print_Version_Info is
278257
begin
279-
Print (Executable & " " & Version_String, Log_Message => False);
258+
Print (Executable & " " & Version_String);
280259
Print
281-
("Copyright "
282-
& Image (Released_At)
283-
& '-'
284-
& Current_Year
285-
& ", AdaCore.",
260+
("Copyright (C) " & "2004" & '-' & Current_Year & ", AdaCore.",
286261
Log_Message => False);
287262
end Print_Version_Info;
288263

@@ -462,7 +437,7 @@ package body Gnatcheck.Output is
462437
Put_Line
463438
("usage: gnatkp -Pproject [options] [-rules [-from=file] {+Rkp_id[:param]}]");
464439
Put_Line ("options:");
465-
Put_Line (" --version - Display version and exit");
440+
Put_Line (" -V, --version - Display version and exit");
466441
Put_Line (" -h, --help - Display usage and exit");
467442
Put_Line ("");
468443
Put_Line
@@ -529,7 +504,7 @@ package body Gnatcheck.Output is
529504
Put_Line
530505
("usage: gnatcheck [options] {filename} {-files=filename} -rules rule_switches [-cargs gcc_switches]");
531506
Put_Line ("options:");
532-
Put_Line (" --version - Display version and exit");
507+
Put_Line (" -V, --version - Display version and exit");
533508
Put_Line (" -h, --help - Display usage and exit");
534509
Put_Line ("");
535510
Put_Line

lkql_checker/src/gnatcheck-output.ads

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@ package Gnatcheck.Output is
1313
-- Whether a warning message has been emitted while "warnings as errors"
1414
-- mode is enabled. This ensure the return code of GNATcheck is not 0.
1515

16-
procedure Print_Version_Info (Released_At : Positive);
16+
procedure Print_Version_Info;
1717
-- Prints into Stderr the tool version information in the following format:
1818
--
19-
-- <toolname>
20-
-- Copyright <Released_At>-<current year>, AdaCore.
21-
--
22-
-- Released_At is supposed to be the year when the tool is first released.
23-
24-
procedure Print_Tool_Version (Released_At : Positive);
25-
-- Similar to Print_Version_Info, but sends the output into Stdout and
26-
-- the format of the information printed is similar to what is printed
27-
-- for '--version' option by all the other GNAT tools.
19+
-- (gnatcheck|gnatkp) <version> (<date>)
20+
-- Copyright (C) 2004-<current year>, AdaCore.
2821

2922
procedure Report_Unhandled_Exception (Ex : Exception_Occurrence);
3023
-- Reports an unhandled exception into Standard_Error

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ package body Gnatcheck.Projects is
11361136
if Arg.Verbose.Get and then not Arg.Aggregated_Project then
11371137
-- When processing aggregated projects one by one, we want
11381138
-- Verbose_Mode to print this only in the outer invocation.
1139-
Print_Version_Info (2004);
1139+
Print_Version_Info;
11401140
end if;
11411141

11421142
-- We generate the rule help unconditionally

lkql_checker/src/gnatcheck_main.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ begin
396396
Scan_Arguments (First_Pass => True);
397397

398398
if Arg.Version.Get then
399-
Print_Tool_Version (2004);
399+
Print_Version_Info;
400400
OS_Exit (E_Success);
401401

402402
elsif Arg.Help.Get then

lkql_jit/cli/src/main/java/com/adacore/lkql_jit/cli/LKQLMain.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
LKQLRefactor.class,
2424
},
2525
description = "Unified driver for LKQL (Langkit query language). Allows you to run LKQL " +
26-
"scripts or apply specific checks on a given Ada codebase"
26+
"scripts or apply specific checks on a given Ada codebase",
27+
// Version information are substituted by anod for production builds
28+
version = { "lkql 26.0w (unknown date)", "Copyright (C) 2004-2025, AdaCore." }
2729
)
2830
public class LKQLMain implements Callable<Integer> {
2931

testsuite/drivers/gnatcheck_driver.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,12 @@ def output_refiners(self) -> list[OutputRefiner]:
697697
"gnatcheck <version> (<date>)",
698698
)
699699
)
700-
result.append(PatternSubstitute("Copyright [0-9-]+", "Copyright <date>"))
700+
result.append(
701+
PatternSubstitute(
702+
"Copyright \\(C\\) [0-9-]+",
703+
"Copyright (C) <date>"
704+
)
705+
)
701706

702707
# Remove project search path information
703708
result.append(PatternSubstitute(

testsuite/tests/gnatcheck/lkql_rules_merging/merge_sets/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rules1.lkql:7:20: info: register new instance sc1
1111
rules1.lkql:8:20: info: register new instance sc2
1212
rules2.lkql:6:13: warning: instance rule2b runs the same check than instance rule2 declared at rules1.lkql:6:5
1313
gnatcheck <version> (<date>)
14-
Copyright <date>, AdaCore.
14+
Copyright (C) <date>, AdaCore.
1515
test.adb:1:01: rule violation: rule2 [rule2]
1616
test.adb:1:01: rule violation: rule2 [rule2b|rule2]
1717
test.adb:1:11: rule violation: rule1 [name1d|rule1]

testsuite/tests/gnatcheck/lkql_rules_merging/merge_sets_error_1/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rules2.lkql:5:14: error: instance name1b has a different configuration than the
55
rules1.lkql:4:5: info: register new instance rule2
66
rules2.lkql:6:5: warning: ignore duplicate instance rule2, previous declaration at rules1.lkql:4:5
77
gnatcheck <version> (<date>)
8-
Copyright <date>, AdaCore.
8+
Copyright (C) <date>, AdaCore.
99
gnatcheck: error: no rule to check specified
1010
try "gnatcheck --help" for more information.
1111
>>>program returned status code 2

0 commit comments

Comments
 (0)