~ubuntu-branches/debian/stretch/adabrowse/stretch

« back to all changes in this revision

Viewing changes to ad-messages.adb

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2004-02-14 13:22:40 UTC
  • Revision ID: james.westby@ubuntu.com-20040214132240-cqumhiq1677pkvzo
Tags: upstream-4.0.2
ImportĀ upstreamĀ versionĀ 4.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-------------------------------------------------------------------------------
 
2
--
 
3
--  This file is part of AdaBrowse.
 
4
--
 
5
-- <STRONG>Copyright (c) 2002 by Thomas Wolf.</STRONG>
 
6
-- <BLOCKQUOTE>
 
7
--    AdaBrowse is free software; you can redistribute it and/or modify it
 
8
--    under the terms of the  GNU General Public License as published by the
 
9
--    Free Software  Foundation; either version 2, or (at your option) any
 
10
--    later version. AdaBrowse is distributed in the hope that it will be
 
11
--    useful, but <EM>without any warranty</EM>; without even the implied
 
12
--    warranty of <EM>merchantability or fitness for a particular purpose.</EM>
 
13
--    See the GNU General Public License for  more details. You should have
 
14
--    received a copy of the GNU General Public License with this distribution,
 
15
--    see file "<A HREF="GPL.txt">GPL.txt</A>". If not, write to the Free
 
16
--    Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
17
--    USA.
 
18
-- </BLOCKQUOTE>
 
19
--
 
20
-- <DL><DT><STRONG>
 
21
-- Author:</STRONG><DD>
 
22
--   Thomas Wolf  (TW)
 
23
--   <ADDRESS><A HREF="mailto:twolf@acm.org">twolf@acm.org</A></ADDRESS></DL>
 
24
--
 
25
-- <DL><DT><STRONG>
 
26
-- Purpose:</STRONG><DD>
 
27
--   File output routines, writing to a file or stdout, as needed.</DL>
 
28
--
 
29
-- <!--
 
30
-- Revision History
 
31
--
 
32
--   19-MAR-2002   TW  First release.
 
33
--   18-JUN-2002   TW  Added 'Debug'.
 
34
--   22-NOV-2002   TW  Added description of "-private" option.
 
35
-- -->
 
36
-------------------------------------------------------------------------------
 
37
 
 
38
pragma License (GPL);
 
39
 
 
40
with Ada.Text_IO;
 
41
 
 
42
with Util.Strings;
 
43
 
 
44
with AD.Version;
 
45
 
 
46
pragma Elaborate_All (AD.Version);
 
47
 
 
48
package body AD.Messages is
 
49
 
 
50
   Level : Verbosity := All_Messages;
 
51
 
 
52
   procedure Set_Mode
 
53
     (To : in Verbosity)
 
54
   is
 
55
   begin
 
56
      Level := To;
 
57
   end Set_Mode;
 
58
 
 
59
   function Get_Mode
 
60
     return Verbosity
 
61
   is
 
62
   begin
 
63
      return Level;
 
64
   end Get_Mode;
 
65
 
 
66
   procedure Info
 
67
     (Msg : in String)
 
68
   is
 
69
   begin
 
70
      if Level < All_Messages then return; end if;
 
71
      Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error,
 
72
                            "adabrowse: Info: " & Msg);
 
73
   end Info;
 
74
 
 
75
   procedure Warn
 
76
     (Msg : in String)
 
77
   is
 
78
   begin
 
79
      if Level < Errors_And_Warnings then return; end if;
 
80
      Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error,
 
81
                            "adabrowse: Warning: " & Msg);
 
82
   end Warn;
 
83
 
 
84
   procedure Error
 
85
     (Msg : in String)
 
86
   is
 
87
   begin
 
88
      Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error,
 
89
                            "adabrowse: Error: " & Msg);
 
90
   end Error;
 
91
 
 
92
   procedure Debug
 
93
     (Msg : in String)
 
94
   is
 
95
   begin
 
96
      if Level < Including_Debug then return; end if;
 
97
      Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error,
 
98
                            "adabrowse: DBG: " & Msg);
 
99
   end Debug;
 
100
 
 
101
   LF   : constant Character := ASCII.LF;
 
102
 
 
103
   Help : constant String :=
 
104
     "NAME" & LF &
 
105
     "   adabrowse" & LF &
 
106
     LF &
 
107
     "SYNOPSIS" & LF &
 
108
     "   adabrowse (-h | -help | --help | -?)" & LF &
 
109
     "   adabrowse {-v | -version | --version | -f file_name | -g |" & LF &
 
110
     "              -c file_name | -s URL | -o file_name | -a | -all | --all |"
 
111
     & LF &
 
112
     "              (-i | -is | -p | -t) [filename] | (-I | -T) directory"
 
113
     & LF &
 
114
     "              (-G (html [xml] | xml [html]) | -l | " &
 
115
                    "-[-]private |" & LF &
 
116
     "              -P file_name | -w(0|1|2|e|w|i|a)}"
 
117
     & LF &
 
118
     LF &
 
119
     "DESCRIPTION" & LF &
 
120
     LF &
 
121
     "   AdaBrowse " & AD.Version.Get_Version & LF &
 
122
     LF &
 
123
     "   AdaBrowse generates HTML documentation from Ada 95 specifications."
 
124
     & LF &
 
125
     "   It can also produce XML 1.0 output instead of or in addition to HTML"
 
126
     &  LF &
 
127
     "   output." & LF &
 
128
     LF &
 
129
     "OPTIONS" & LF &
 
130
     "   The following options are available in AdaBrowse:" & LF &
 
131
     LF &
 
132
     "   -h" & LF &
 
133
     "   -?" & LF &
 
134
     "   -help" & LF &
 
135
     "   --help         Writes this help text." & LF &
 
136
     "   -a" & LF &
 
137
     "   -all" & LF &
 
138
     "   --all          Generate HTML not only for the unit given"
 
139
     & LF &
 
140
     "                  in the -f option, but also for all application units"
 
141
     & LF &
 
142
     "                  on which it depends semantically (""with""es and"
 
143
     & LF &
 
144
     "                  parent units)." & LF &
 
145
     "   -c filename    Defines a config file for the HTML " &
 
146
     "generator." & LF &
 
147
     "                  Multiple -c options may be given; the files are" & LF &
 
148
     "                  processed in the given order and may overwrite" & LF &
 
149
     "                  earlier config settings." & LF &
 
150
     "   -f filename    Gives the filename (*.ads) of the spec to process."
 
151
     & LF &
 
152
     "                  The file name may contain a path; if it starts with"
 
153
     & LF &
 
154
     "                  '@', AdaBrowse reads unit specs from the given file."
 
155
     & LF &
 
156
     "                  If it is '-', AdaBrowse reads the unit specs from"
 
157
     & LF &
 
158
     "                  stdin. Only one -f option may be given."
 
159
     & LF &
 
160
     "   -g             Generate cross-references to the standard"
 
161
     & LF &
 
162
     "                  library, too." & LF &
 
163
     "   -G {format}    Specify the output format(s). Recognized"
 
164
     & LF &
 
165
     "                  output format names are ""html"" and ""xml"" (as"
 
166
     & LF &
 
167
     "                  separate arguments). If no -G option is given, the"
 
168
     & LF &
 
169
     "                  default output format is html."
 
170
     & LF &
 
171
     "   -i [filename]  Generate a unit index if unit specs are"
 
172
     & LF &
 
173
     "                  read from a file and the output does *not* go to"
 
174
     & LF &
 
175
     "                  stdout." & LF &
 
176
     "   -is [filename] As -i, but generates a structured unit " &
 
177
     "index." & LF &
 
178
     "   -l             Use only the line number in HTML cross-" &
 
179
     "references." &  LF &
 
180
     "   -o filename    Define the output file name. If not set,"
 
181
     & LF &
 
182
     "                  the output goes to a file with the name of the input"
 
183
     & LF &
 
184
     "                  and suffix "".html"". If the filename is '-', output"
 
185
     & LF &
 
186
     "                  is written to stdout. If the filename is a directory,"
 
187
     & LF &
 
188
     "                  all generated HTML files will be put there. Only one"
 
189
     & LF &
 
190
     "                  -o option may be given." & LF &
 
191
     "   -p [filename]  As -i, but generates an index of all " &
 
192
     "subprograms." & LF &
 
193
     "   -P filename    Process the GNAT project file 'file_name'. Only one"
 
194
     & LF &
 
195
     "                  -P option may be given." & LF &
 
196
     "   -private" & LF &
 
197
     "   --private      Also process the private part of packages and task "
 
198
     & LF &
 
199
     "                  and protected declarations." & LF &
 
200
     "   -q             ""Quiet"" mode: do not issue warning " &
 
201
                        "or info messages." & LF &
 
202
     "                  Synonym for ""-w0""." & LF &
 
203
     "   -s URL         Defines the URL to the style sheet the"
 
204
     & LF &
 
205
     "                  generated HTML file shall use. This URL should be"
 
206
     & LF &
 
207
     "                  relative to the final place where you will put the"
 
208
     & LF &
 
209
     "                  HTML files! Note that a -s option can be overwritten"
 
210
     & LF &
 
211
     "                  by a later -c option, if the configuration file " &
 
212
     "defines" & LF &
 
213
     "                  the key ""Style_Sheet""." & LF &
 
214
     "   -t [filename]  As -i, but generates a global index of all"
 
215
     & LF &
 
216
     "                  types." & LF &
 
217
     "   -v" & LF &
 
218
     "   -version" & LF &
 
219
     "   --version      Print version information of AdaBrowse to"
 
220
     & LF &
 
221
     "                  stderr." & LF &
 
222
     "   -wi            Set the warning level. 'i' can be one of:"
 
223
     & LF &
 
224
     "                    '0', or 'e'         : print only error messages."
 
225
     & LF &
 
226
     "                    '1', or 'w'         : print warnings and errors."
 
227
     & LF &
 
228
     "                    '2', or 'a', or 'i' : print all messages." & LF &
 
229
     "                    'D'                 : print even debug information."
 
230
     & LF &
 
231
     "   -x             If set, AdaBrowse never overwrites existing"
 
232
     & LF &
 
233
     "                  HTML Files. (May be useful in conjunction with the -a"
 
234
     & LF &
 
235
     "                  option.)" & LF &
 
236
     "   -I directory   Define source pathes. Same semantics as"
 
237
     & LF &
 
238
     "                  for GNAT." & LF &
 
239
     "   -T directory   Define pathes for ASIS to search for tree"
 
240
     & LF &
 
241
     "                  files (*.adt). Multiple -T options may be given."
 
242
     & LF & LF &
 
243
     "One of -f or -P must be given on the command line; if there is a -P but"
 
244
     & LF &
 
245
     "no -f, AdaBrowse processes all source files from the given project.";
 
246
 
 
247
 
 
248
   procedure Help_Text
 
249
   is
 
250
      Start : Natural := Help'First;
 
251
      I     : Natural;
 
252
   begin
 
253
      while Start <= Help'Last loop
 
254
         I := Util.Strings.Index (Help (Start .. Help'Last), ASCII.LF);
 
255
         if I = 0 then I := Help'Last + 1; end if;
 
256
         Ada.Text_IO.Put_Line
 
257
           (Ada.Text_IO.Current_Error, Help (Start .. I - 1));
 
258
         Start := I + 1;
 
259
      end loop;
 
260
   end Help_Text;
 
261
 
 
262
end AD.Messages;