PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/cli/internal/clarg_not.e

http://github.com/tybor/Liberty
Specman e | 114 lines | 74 code | 17 blank | 23 comment | 2 complexity | c966316a713da8b3056c4ab29515b78f MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4class CLARG_NOT
  5
  6inherit
  7   COMMAND_LINE_ARGUMENT
  8      redefine
  9         prefix "not"
 10      end
 11
 12create {COMMAND_LINE_ARGUMENT}
 13   make
 14
 15feature {ANY}
 16   is_repeatable: BOOLEAN False
 17
 18   prefix "not": COMMAND_LINE_ARGUMENT
 19      do
 20         Result := arg
 21      end
 22
 23   is_set: BOOLEAN
 24      do
 25         Result := not arg.is_set
 26      end
 27
 28   is_mandatory: BOOLEAN
 29      do
 30         Result := arg.is_mandatory
 31      end
 32
 33   is_set_at (context: COMMAND_LINE_CONTEXT): BOOLEAN
 34      do
 35         Result := not arg.is_set_at(context)
 36      end
 37
 38feature {COMMAND_LINE_ARGUMENTS, COMMAND_LINE_ARGUMENT}
 39   prepare_parse
 40      do
 41         arg.prepare_parse
 42      end
 43
 44   parse_command_line (context: COMMAND_LINE_CONTEXT): COMMAND_LINE_CONTEXT
 45      do
 46         Result := arg.parse_command_line(context)
 47         if not Result.is_parsed then
 48            Result := Result.default
 49         elseif arg.is_set then
 50            arg.undo_parse(context)
 51            Result := context
 52         end
 53      end
 54
 55   undo_parse (context: COMMAND_LINE_CONTEXT)
 56      do
 57         arg.undo_parse(context)
 58      end
 59
 60   usage_summary (stream: OUTPUT_STREAM)
 61      local
 62         i: INTEGER
 63      do
 64         stream.put_character('~')
 65         stream.put_character('(')
 66         arg.usage_summary(stream)
 67         stream.put_character(')')
 68         detailed := False
 69      end
 70
 71   usage_details (stream: OUTPUT_STREAM)
 72      do
 73         if not detailed then
 74            arg.usage_details(stream)
 75            detailed := True
 76         end
 77      end
 78
 79feature {}
 80   arg: COMMAND_LINE_ARGUMENT
 81
 82   make (a_arg: COMMAND_LINE_ARGUMENT)
 83      require
 84         a_arg /= Void
 85      do
 86         arg := a_arg
 87      end
 88
 89   detailed: BOOLEAN
 90
 91invariant
 92   arg /= Void
 93
 94end -- class CLARG_NOT
 95--
 96-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
 97--
 98-- Permission is hereby granted, free of charge, to any person obtaining a copy
 99-- of this software and associated documentation files (the "Software"), to deal
100-- in the Software without restriction, including without limitation the rights
101-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
102-- copies of the Software, and to permit persons to whom the Software is
103-- furnished to do so, subject to the following conditions:
104--
105-- The above copyright notice and this permission notice shall be included in
106-- all copies or substantial portions of the Software.
107--
108-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
111-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
113-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
114-- THE SOFTWARE.