예제 #1
0
    static public bool TryParseCommandLine(string[] args, out Output.ToolAction action, out string configFile)
    {
      Contract.Requires(args != null);
      Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out configFile) != null);

      configFile = null;

      if(args.Length == 0)
      {
        action = Output.ToolAction.Run;
        configFile = Constants.String.ConfigDefault;

        return true;
      }

      if(args.Length == 1)
      {
        if (args[0].ToLower() == "-createdefaultconfig")
        {
          action = Output.ToolAction.CreateDefaultFile;
        }
        else
        {
          action = Output.ToolAction.Run;
          configFile = args[0];
          Contract.Assume(configFile != null);
        }
        return true;
      }

      action = Output.ToolAction.PrintUsage;
      return false;
    }