// Path: src/main/java/net/nandgr/cba/custom/model/Rules.java
// public class Rules {
// 
//   private List<Rule> rules;
// 
//   public List<Rule> getRules() {
//     return rules;
//   }
// 
//   public void setRules(List<Rule> rules) {
//     this.rules = rules;
//   }
// 
//   @Override
//   public String toString() {
//     return "Rules{" +
//             "rules=" + Arrays.toString(rules.toArray()) +
//             '}';
//   }
// 
//   public void validateRules() throws BadRulesException {
//     for (Rule rule : this.getRules()) {
//       if (StringUtils.isBlank(rule.getName())) {
//         throw new BadRulesException("Rule name cannot be blank.");
//       }
//       validateRule(rule);
//     }
//   }
// 
//   private static void validateRule(Rule rule) throws BadRulesException {
//     if (rule.getInvocations() != null) {
//       for (Invocation invocation : rule.getInvocations()) {
// 
//         Method notFrom = invocation.getNotFrom();
//         checkEmpty(notFrom, "\"invocation.notFrom\" property cannot have all the fields blank.");
// 
//         Method from = invocation.getFrom();
//         checkEmpty(from, "\"invocation.from\" property cannot have all the fields blank.");
// 
//         Method method = invocation.getMethod();
//         checkEmpty(method, "\"invocation.method\" property cannot have all the fields blank.");
// 
//         if (notFrom != null && from != null) {
//           throw new BadRulesException("\"invocation.notFrom\" and \"invocation.from\" cannot be defined at the same time in the same rule.");
//         }
//       }
//     }
//   }
// 
//   private static void checkEmpty(Method method, String message) throws BadRulesException {
//     if (allEmpty(method)) {
//       throw new BadRulesException(message);
//     }
//   }
// }


import net.nandgr.cba.custom.model.Rules;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.ParseException;
/*
 * Copyright (c) 2016-2017, Fernando Garcia
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.nandgr.cba.cli;


public class CliHelper {

  private static CommandLineParser commandLineParser = new DefaultParser();
  private static CommandLine commandLine;
// Path: src/main/java/net/nandgr/cba/custom/model/Rules.java
// public class Rules {
// 
//   private List<Rule> rules;
// 
//   public List<Rule> getRules() {
//     return rules;
//   }
// 
//   public void setRules(List<Rule> rules) {
//     this.rules = rules;
//   }
// 
//   @Override
//   public String toString() {
//     return "Rules{" +
//             "rules=" + Arrays.toString(rules.toArray()) +
//             '}';
//   }
// 
//   public void validateRules() throws BadRulesException {
//     for (Rule rule : this.getRules()) {
//       if (StringUtils.isBlank(rule.getName())) {
//         throw new BadRulesException("Rule name cannot be blank.");
//       }
//       validateRule(rule);
//     }
//   }
// 
//   private static void validateRule(Rule rule) throws BadRulesException {
//     if (rule.getInvocations() != null) {
//       for (Invocation invocation : rule.getInvocations()) {
// 
//         Method notFrom = invocation.getNotFrom();
//         checkEmpty(notFrom, "\"invocation.notFrom\" property cannot have all the fields blank.");
// 
//         Method from = invocation.getFrom();
//         checkEmpty(from, "\"invocation.from\" property cannot have all the fields blank.");
// 
//         Method method = invocation.getMethod();
//         checkEmpty(method, "\"invocation.method\" property cannot have all the fields blank.");
// 
//         if (notFrom != null && from != null) {
//           throw new BadRulesException("\"invocation.notFrom\" and \"invocation.from\" cannot be defined at the same time in the same rule.");
//         }
//       }
//     }
//   }
// 
//   private static void checkEmpty(Method method, String message) throws BadRulesException {
//     if (allEmpty(method)) {
//       throw new BadRulesException(message);
//     }
//   }
// }


// Path: src/main/java/net/nandgr/cba/cli/CliHelper.java
import net.nandgr.cba.custom.model.Rules;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.ParseException;

/*
 * Copyright (c) 2016-2017, Fernando Garcia
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.nandgr.cba.cli;


public class CliHelper {

  private static CommandLineParser commandLineParser = new DefaultParser();
  private static CommandLine commandLine;
  private static Rules rules;