Skip to main content
summaryrefslogtreecommitdiffstats
blob: 915dac5f48bbeb6dffb1ce74e57b362023d02aae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.jdk.core.util;

import java.util.HashMap;

public class CmdLineArgs {

   private final HashMap<String, String> cmdArgs;

   public CmdLineArgs(String[] args) {
      cmdArgs = new HashMap<>();

      for (int i = 0; i < args.length; i++) {
         if (args[i].matches("-\\w.*")) {
            if (i + 1 < args.length && !args[i + 1].matches("-\\D.*")) {
               cmdArgs.put(args[i], args[i + 1]);
               i++;
            } else {
               cmdArgs.put(args[i], null);
            }
         } else {
            cmdArgs.put(args[i], null);
         }
      }
   }

   public String get(String key) {
      return cmdArgs.get(key);
   }

   public HashMap<String, String> getArgs() {
      return cmdArgs;
   }
}

Back to the top