| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT RUN-TIME COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- A D A . C O M M A N D _ L I N E . R E M O V E -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1999-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- This package is intended to be used in conjunction with its parent unit, |
| 33 |
-- Ada.Command_Line. It provides facilities for logically removing arguments |
| 34 |
-- from the command line, so that subsequent calls to Argument_Count and |
| 35 |
-- Argument will reflect the removals. |
| 36 |
|
| 37 |
-- For example, if the original command line has three arguments A B C, so |
| 38 |
-- that Argument_Count is initially three, then after removing B, the second |
| 39 |
-- argument, Argument_Count will be 2, and Argument (2) will return C. |
| 40 |
|
| 41 |
package Ada.Command_Line.Remove is |
| 42 |
pragma Preelaborate; |
| 43 |
|
| 44 |
procedure Remove_Argument (Number : Positive); |
| 45 |
-- Removes the argument identified by Number, which must be in the |
| 46 |
-- range 1 .. Argument_Count (i.e. an in range argument number which |
| 47 |
-- reflects removals). If Number is out of range Constraint_Error |
| 48 |
-- will be raised. |
| 49 |
-- |
| 50 |
-- Note: the numbering of arguments greater than Number is affected |
| 51 |
-- by the call. If you need a loop through the arguments, removing |
| 52 |
-- some as you go, run the loop in reverse to avoid confusion from |
| 53 |
-- this renumbering: |
| 54 |
-- |
| 55 |
-- for J in reverse 1 .. Argument_Count loop |
| 56 |
-- if Should_Remove (Arguments (J)) then |
| 57 |
-- Remove_Argument (J); |
| 58 |
-- end if; |
| 59 |
-- end loop; |
| 60 |
-- |
| 61 |
-- Reversing the loop in this manner avoids the confusion. |
| 62 |
|
| 63 |
procedure Remove_Arguments (From : Positive; To : Natural); |
| 64 |
-- Removes arguments in the given From..To range. From must be in the |
| 65 |
-- range 1 .. Argument_Count and To in the range 0 .. Argument_Count. |
| 66 |
-- Constraint_Error is raised if either argument is out of range. If |
| 67 |
-- To is less than From, then the call has no effect. |
| 68 |
|
| 69 |
procedure Remove_Argument (Argument : String); |
| 70 |
-- Removes the argument which matches the given string Argument. Has |
| 71 |
-- no effect if no argument matches the string. If more than one |
| 72 |
-- argument matches the string, all are removed. |
| 73 |
|
| 74 |
procedure Remove_Arguments (Argument_Prefix : String); |
| 75 |
-- Removes all arguments whose prefix matches Argument_Prefix. Has |
| 76 |
-- no effect if no argument matches the string. For example a call |
| 77 |
-- to Remove_Arguments ("--") removes all arguments starting with --. |
| 78 |
|
| 79 |
end Ada.Command_Line.Remove; |