
with Ada.Strings.Fixed;
use Ada.Strings;


package body Adam.Values is
   function Value(Default : in Command_Type;
	       Command_Line : in String) return Command_Type is
   begin
      if Fixed.Index(Command_Line, " ") > Fixed.Index_Non_Blank(Command_Line) then
	 return Command_Type'Value(Command_Line(Command_Line'first..Fixed.Index(Command_Line, " ")));
      else
	 return Command_Type'Value(Command_Line);
      end if;
   exception
      when others =>
      return Default;
   end Value;
   
   
   function Sub_Value(Default : in Sub_Command_Type;
	       Command_Line : in String) return Sub_Command_Type is
   begin
      if Fixed.Index(Command_Line, " ") > Fixed.Index_Non_Blank(Command_Line) then
	 return Sub_Command_Type'Value(Command_Line(Command_Line'first..Fixed.Index(Command_Line, " ")));
      else
	 return Sub_Command_Type'Value(Command_Line);
      end if;
   exception
      when others =>
      return Default;
   end Sub_Value;
end Adam.Values;
