/src/lib/cli/internal/clarg_with_args.e

http://github.com/tybor/Liberty · Specman e · 144 lines · 98 code · 23 blank · 23 comment · 0 complexity · 204b3d6be5a48915ca9f25bb90af4b4b MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class CLARG_WITH_ARGS[E_]
  5. inherit
  6. TRAVERSABLE[E_]
  7. undefine
  8. out_in_tagged_out_memory
  9. end
  10. COMMAND_LINE_TYPED_ARGUMENT[TRAVERSABLE[E_]]
  11. rename
  12. item as items
  13. undefine
  14. out_in_tagged_out_memory
  15. end
  16. insert
  17. CLARG_PARSER
  18. redefine
  19. optional, positional
  20. end
  21. feature {ANY}
  22. items: TRAVERSABLE[E_]
  23. do
  24. Result := Current
  25. end
  26. is_repeatable: BOOLEAN True
  27. is_set: BOOLEAN
  28. do
  29. Result := not set.is_empty
  30. end
  31. feature {COMMAND_LINE_ARGUMENTS, COMMAND_LINE_ARGUMENT}
  32. prepare_parse
  33. do
  34. set.clear_count
  35. end
  36. is_set_at (context: COMMAND_LINE_CONTEXT): BOOLEAN
  37. do
  38. Result := set.has(context)
  39. end
  40. undo_parse (context: COMMAND_LINE_CONTEXT)
  41. do
  42. set.remove(context)
  43. end
  44. set_data (context: COMMAND_LINE_CONTEXT; data: STRING)
  45. do
  46. set.add(decode(data), context)
  47. end
  48. feature {}
  49. decode (data: STRING): E_
  50. require
  51. is_valid_data(data)
  52. deferred
  53. end
  54. feature {ANY} -- TRAVERSABLE:
  55. count: INTEGER
  56. do
  57. Result := set.count
  58. end
  59. is_empty: BOOLEAN
  60. do
  61. Result := set.is_empty
  62. end
  63. lower: INTEGER
  64. do
  65. Result := set.lower
  66. end
  67. upper: INTEGER
  68. do
  69. Result := set.upper
  70. end
  71. item (i: INTEGER): E_
  72. do
  73. Result := set.item(i)
  74. end
  75. first: like item
  76. do
  77. Result := set.first
  78. end
  79. last: like item
  80. do
  81. Result := set.last
  82. end
  83. new_iterator: ITERATOR[E_]
  84. do
  85. Result := set.new_iterator_on_items
  86. end
  87. feature {}
  88. set: AVL_DICTIONARY[E_, COMMAND_LINE_CONTEXT]
  89. optional (a_short, a_long, a_name, a_usage: ABSTRACT_STRING)
  90. do
  91. create set.make
  92. Precursor(a_short, a_long, a_name, a_usage)
  93. end
  94. positional (a_name, a_usage: ABSTRACT_STRING)
  95. do
  96. create set.make
  97. Precursor(a_name, a_usage)
  98. end
  99. invariant
  100. set /= Void
  101. end -- class CLARG_WITH_ARGS
  102. --
  103. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  104. --
  105. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  106. -- of this software and associated documentation files (the "Software"), to deal
  107. -- in the Software without restriction, including without limitation the rights
  108. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  109. -- copies of the Software, and to permit persons to whom the Software is
  110. -- furnished to do so, subject to the following conditions:
  111. --
  112. -- The above copyright notice and this permission notice shall be included in
  113. -- all copies or substantial portions of the Software.
  114. --
  115. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  116. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  117. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  118. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  119. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  120. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  121. -- THE SOFTWARE.