This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 32053
Collapse All | Expand All

(-)core/bootstrap/src/org/netbeans/CLIHandler.java (-14 / +10 lines)
Lines 86-94 public abstract class CLIHandler extends Link Here
86
    protected abstract int cli(Args args);
86
    protected abstract int cli(Args args);
87
    
87
    
88
    private static void showHelp(PrintWriter w, List handlers) {
88
    private static void showHelp(PrintWriter w, List handlers) {
89
        w.println("-?");
89
//        w.println("  -? or --help          Show this help information.");
90
        w.println("--help");
91
        w.println("  Show this help information.");
92
        Iterator it = handlers.iterator();
90
        Iterator it = handlers.iterator();
93
        while (it.hasNext()) {
91
        while (it.hasNext()) {
94
            ((CLIHandler)it.next()).usage(w);
92
            ((CLIHandler)it.next()).usage(w);
Lines 128-143 public abstract class CLIHandler extends Link Here
128
    private static int notifyHandlers(Args args, List handlers, int when, boolean failOnUnknownOptions, boolean consume) {
126
    private static int notifyHandlers(Args args, List handlers, int when, boolean failOnUnknownOptions, boolean consume) {
129
        try {
127
        try {
130
            //System.err.println("notifyHandlers: handlers=" + handlers + " when=" + when + " args=" + Arrays.asList(args.getArguments()));
128
            //System.err.println("notifyHandlers: handlers=" + handlers + " when=" + when + " args=" + Arrays.asList(args.getArguments()));
131
            if (failOnUnknownOptions) {
129
            String[] argv = args.getArguments();
132
                String[] argv = args.getArguments();
130
            for (int i = 0; i < argv.length; i++) {
133
                for (int i = 0; i < argv.length; i++) {
131
                assert argv[i] != null;
134
                    assert argv[i] != null;
132
                if (argv[i].equals("-?") || argv[i].equals("--help") || argv[i].equals ("-help")) { // NOI18N
135
                    if (argv[i].equals("-?") || argv[i].equals("--help") || argv[i].equals ("-help")) { // NOI18N
133
                    PrintWriter w = new PrintWriter(args.getOutputStream());
136
                        PrintWriter w = new PrintWriter(args.getOutputStream());
134
                    showHelp(w, handlers);
137
                        showHelp(w, handlers);
135
                    w.flush();
138
                        w.flush();
136
                    return 2;
139
                        return 2;
140
                    }
141
                }
137
                }
142
            }
138
            }
143
            int r = 0;
139
            int r = 0;
Lines 153-159 public abstract class CLIHandler extends Link Here
153
                }
149
                }
154
            }
150
            }
155
            if (failOnUnknownOptions) {
151
            if (failOnUnknownOptions) {
156
                String[] argv = args.getArguments();
152
                argv = args.getArguments();
157
                for (int i = 0; i < argv.length; i++) {
153
                for (int i = 0; i < argv.length; i++) {
158
                    if (argv[i] != null) {
154
                    if (argv[i] != null) {
159
                        // Unhandled option.
155
                        // Unhandled option.
(-)core/release/bin/runide.sh (-32 / +16 lines)
Lines 95-133 parse_args() { Link Here
95
while [ $# -gt 0 ] ; do
95
while [ $# -gt 0 ] ; do
96
#    echo "Processing arg: '$1'"
96
#    echo "Processing arg: '$1'"
97
    case "$1" in
97
    case "$1" in
98
        -h|-help) cat >&2 <<EOF
98
        -h|-?|-help|--help) cat >&2 <<EOF
99
Usage: $0 {options} arguments
99
Usage: $0 {options} arguments
100
100
101
Options can be
101
General options:
102
102
  --help                show this help 
103
   -h -help
103
  --jdkhome <path>      path to JDK (could also be just JRE but some modules may not work!)
104
        shows usage
104
  -J<jvm_options>       passes <jvm_option> to JVM
105
   -?
105
Classpath options:
106
        help on more parameters (not interpreted by launcher)
106
  --cp:p <classpath>    prepends <classpath> to classpath
107
   -jdkhome <path>
107
  --cp:a <classpath>    appends <classpath> to classpath
108
        path to JDK (could also be just JRE but some modules may not work!)
109
   -userdir <path>
110
        specifies user settings directory (${userdir} by default)
111
   -J<jvm_options>
112
        passes <jvm_option> to JVM
113
Classpath options (normally you should NOT use these except to support -ui):
114
   -cp:p <classpath>
115
        prepends <classpath> to IDE's classpath
116
   -cp:a <classpath>
117
        appends <classpath> to IDE's classpath
118
119
All other options and arguments are passed to the IDE, so try -? for more.
120
Any options found in $HOME/ide.cfg or else $idehome/bin/ide.cfg
121
are treated as defaults (may be overridden).
122
See documentation for details.
123
EOF
108
EOF
124
exit 2
109
            # go on and print IDE options as well
125
;;
110
            args="$args --help" ;;
126
        -jdkhome) shift; if [ $# -gt 0 ] ; then jdkhome=$1; fi;;
111
        -jdkhome|--jdkhome) shift; if [ $# -gt 0 ] ; then jdkhome=$1; fi;;
127
        -userdir) shift; if [ $# -gt 0 ] ; then userdir=$1; fi;;
128
        # For compatibility only:
112
        # For compatibility only:
129
        -mainclass) shift; if [ $# -gt 0 ] ; then ide_class_option=-Dnetbeans.mainclass=$1; fi;;
113
        -mainclass) shift; if [ $# -gt 0 ] ; then ide_class_option=-Dnetbeans.mainclass=$1; fi;;
130
        -cp|-cp:a)
114
        -cp|-cp:a|--cp|--cp:a)
131
            shift;
115
            shift;
132
            if [ $# -gt 0 ] ; then
116
            if [ $# -gt 0 ] ; then
133
                if [ ! -z "$postfixcp" ] ; then postfixcp="$postfixcp:" ; fi
117
                if [ ! -z "$postfixcp" ] ; then postfixcp="$postfixcp:" ; fi
Lines 135-141 exit 2 Link Here
135
            fi
119
            fi
136
            ;;
120
            ;;
137
        
121
        
138
        -cp:p)
122
        -cp:p|--cp:p)
139
            shift;
123
            shift;
140
            if [ $# -gt 0 ] ; then
124
            if [ $# -gt 0 ] ; then
141
                if [ ! -z "$prefixcp" ] ; then prefixcp="$prefixcp:" ; fi
125
                if [ ! -z "$prefixcp" ] ; then prefixcp="$prefixcp:" ; fi
Lines 174-187 parse_args "$@" Link Here
174
158
175
if [ -z "$jdkhome" ] ; then
159
if [ -z "$jdkhome" ] ; then
176
    echo "Cannot find JDK. Please set the JDK_HOME environment variable to point" >&2
160
    echo "Cannot find JDK. Please set the JDK_HOME environment variable to point" >&2
177
    echo "to your JDK installation directory, or use the -jdkhome switch" >&2
161
    echo "to your JDK installation directory, or use the --jdkhome switch" >&2
178
    exit 2
162
    exit 2
179
fi
163
fi
180
164
181
if [ ! -x "${jdkhome}/bin/java" ] ; then
165
if [ ! -x "${jdkhome}/bin/java" ] ; then
182
    echo "Cannot find JDK at ${jdkhome}. Please set the JDK_HOME" >&2
166
    echo "Cannot find JDK at ${jdkhome}. Please set the JDK_HOME" >&2
183
    echo "environment variable to point to your JDK installation directory," >&2
167
    echo "environment variable to point to your JDK installation directory," >&2
184
    echo "or use the -jdkhome switch" >&2
168
    echo "or use the --jdkhome switch" >&2
185
    exit 2
169
    exit 2
186
fi
170
fi
187
171
Lines 190-196 fi Link Here
190
#
174
#
191
175
192
if [ ! -z "$userdir" ] ; then
176
if [ ! -z "$userdir" ] ; then
193
    jargs="-Dnetbeans.user=\"${userdir}\" $jargs"
177
    args="--userdir \"${userdir}\" $args"
194
fi
178
fi
195
179
196
#
180
#
(-)core/src/org/netbeans/core/Bundle.properties (-10 / +10 lines)
Lines 150-170 CTL_Nonreg=Non-Commercial Version Link Here
150
# NonGui
150
# NonGui
151
TEXT_help=\
151
TEXT_help=\
152
    Command-line options:\n\
152
    Command-line options:\n\
153
   \  -?                    show this help\n\
153
   \  --ui <UI class name>  use given UI class as the IDE's Look & Feel\n\
154
   \  -h (or -help)         show launcher-specific options\n\
154
   \  --fontsize <size>     use given number as the base font size of the\n\
155
   \  -ui <UI class name>   use given UI class as the IDE's Look & Feel\n\
156
   \  -fontsize <size>      use given number as the base font size of the\n\
157
   \                        IDE user interface, in points (11 default)\n\
155
   \                        IDE user interface, in points (11 default)\n\
158
   \                        (but see http://ui.netbeans.org/docs/ui/themes/themes.html)\n\
156
   \                        (but see http://ui.netbeans.org/docs/ui/themes/themes.html)\n\
159
   \  -locale <language[:country[:variant]]> use specified locale\n\
157
   \  --locale <language[:country[:variant]]> use specified locale\n\
160
    Rarer options (definitely not supported!):\n\
158
   \  --userdir <path>      user settings directory (${userdir} by default)\n\
161
   \  -branding <token>     use specified branding (- for default)\n\
159
   \  --branding <token>    use specified branding (- for default)
162
   \  -nologging            do not create the log file\n\
160
#   
163
   \  -nosplash             do not show the splash screen\n\
161
#   \  --nologging           do not create the log file\n\
164
   \  -nogui                just start up internals, do not show GUI
162
#   \  --nosplash            do not show the splash screen\n\
163
#   \  --nogui               just start up internals, do not show GUI
165
164
166
# error messages
165
# error messages
167
ERR_UIExpected=UI class name expected, using default UI...
166
ERR_UIExpected=UI class name expected, using default UI...
167
ERR_UserDirExpected=Directory expected after --userdir switch
168
ERR_UINotFound=UI class not found, using default UI...
168
ERR_UINotFound=UI class not found, using default UI...
169
ERR_UIError=An error occured when setting the specified UI, using default UI ...
169
ERR_UIError=An error occured when setting the specified UI, using default UI ...
170
ERR_FontSizeExpected=Font size expected, using default font size...
170
ERR_FontSizeExpected=Font size expected, using default font size...
(-)core/src/org/netbeans/core/CLIOptions.java (-8 / +27 lines)
Lines 46-51 public class CLIOptions extends CLIHandl Link Here
46
        return cli(arguments.getArguments());
46
        return cli(arguments.getArguments());
47
    }
47
    }
48
    
48
    
49
    private static boolean isOption (String value, String optionName) {
50
        if (value == null) return false;
51
        
52
        if (value.startsWith ("--")) {
53
            return value.substring (2).equals (optionName);
54
        } else if (value.startsWith ("-")) {
55
            return value.substring (1).equals (optionName);
56
        }
57
        return false;
58
    }
59
    
49
    final int cli(String[] args) {
60
    final int cli(String[] args) {
50
        // let's go through the command line
61
        // let's go through the command line
51
        for (int i = 0; i < args.length; i++) {
62
        for (int i = 0; i < args.length; i++) {
Lines 53-67 public class CLIOptions extends CLIHandl Link Here
53
                continue;
64
                continue;
54
            }
65
            }
55
            boolean used = true;
66
            boolean used = true;
56
            if (args[i].equalsIgnoreCase("-nogui")) { // NOI18N
67
            if (isOption (args[i], "nogui")) { // NOI18N
57
                System.getProperties().put("org.openide.TopManager", "org.netbeans.core.NonGui"); // NOI18N
68
                System.getProperties().put("org.openide.TopManager", "org.netbeans.core.NonGui"); // NOI18N
58
            } else if (args[i].equalsIgnoreCase("-nosplash")) { // NOI18N
69
            } else if (isOption (args[i], "nosplash")) { // NOI18N
59
                NonGui.noSplash = true;
70
                NonGui.noSplash = true;
60
            } else if (args[i].equalsIgnoreCase("-noinfo")) { // NOI18N
71
            } else if (isOption (args[i], "noinfo")) { // NOI18N
61
                // obsolete switch, ignore
72
                // obsolete switch, ignore
62
            } else if (args[i].equalsIgnoreCase("-nologging")) { // NOI18N
73
            } else if (isOption (args[i], "nologging")) { // NOI18N
63
                NonGui.noLogging = true;
74
                NonGui.noLogging = true;
64
            } else if (args[i].equalsIgnoreCase("-ui")) { // NOI18N
75
            } else if (isOption (args[i], "userdir")) { // NOI18N
76
                args[i] = null;
77
                try {
78
                    System.setProperty ("netbeans.user", args[++i]);
79
                } catch(ArrayIndexOutOfBoundsException e) {
80
                    System.err.println(NonGui.getString("ERR_UserDirExpected"));
81
                    return 2;
82
                }
83
            } else if (isOption (args[i], "ui")) { // NOI18N
65
                args[i] = null;
84
                args[i] = null;
66
                try {
85
                try {
67
                    NonGui.uiClass = Class.forName(args[++i]);
86
                    NonGui.uiClass = Class.forName(args[++i]);
Lines 72-78 public class CLIOptions extends CLIHandl Link Here
72
                    System.err.println(NonGui.getString("ERR_UINotFound"));
91
                    System.err.println(NonGui.getString("ERR_UINotFound"));
73
                    return 1;
92
                    return 1;
74
                }
93
                }
75
            } else if (args[i].equalsIgnoreCase("-fontsize")) { // NOI18N
94
            } else if (isOption (args[i], "fontsize")) { // NOI18N
76
                args[i] = null;
95
                args[i] = null;
77
                try {
96
                try {
78
                    NonGui.uiFontSize = Integer.parseInt(args[++i]);
97
                    NonGui.uiFontSize = Integer.parseInt(args[++i]);
Lines 83-89 public class CLIOptions extends CLIHandl Link Here
83
                    System.err.println(NonGui.getString("ERR_BadFontSize"));
102
                    System.err.println(NonGui.getString("ERR_BadFontSize"));
84
                    return 1;
103
                    return 1;
85
                }
104
                }
86
            } else if (args[i].equalsIgnoreCase("-locale")) { // NOI18N
105
            } else if (isOption (args[i], "locale")) { // NOI18N
87
                args[i] = null;
106
                args[i] = null;
88
                String localeParam = args[++i];
107
                String localeParam = args[++i];
89
                String language;
108
                String language;
Lines 103-109 public class CLIOptions extends CLIHandl Link Here
103
                        country = localeParam.substring(index1+1);
122
                        country = localeParam.substring(index1+1);
104
                }
123
                }
105
                Locale.setDefault(new Locale(language, country, variant));
124
                Locale.setDefault(new Locale(language, country, variant));
106
            } else if (args[i].equalsIgnoreCase("-branding")) { // NOI18N
125
            } else if (isOption (args[i], "branding")) { // NOI18N
107
                args[i] = null;
126
                args[i] = null;
108
                String branding = args[++i];
127
                String branding = args[++i];
109
                if (branding.equals("-")) branding = null; // NOI18N
128
                if (branding.equals("-")) branding = null; // NOI18N
(-)utilities/clisrc/org/netbeans/modules/openfile/cli/Handler.java (-70 / +51 lines)
Lines 35-114 public class Handler extends CLIHandler Link Here
35
        return (Callback)Lookup.getDefault().lookup(Callback.class);
35
        return (Callback)Lookup.getDefault().lookup(Callback.class);
36
    }
36
    }
37
    
37
    
38
    private File findFile (File curDir, String name) {
39
        File f = new File(name);
40
        if (!f.isAbsolute()) {
41
            f = new File(curDir, name);
42
        }
43
        return f;
44
    }
45
    
46
    private int openFile (File curDir, CLIHandler.Args args, String[] argv, int i) {
47
        String s = argv[i];
48
        if (s == null) {
49
            log("Missing argument to --open", args);
50
            return 2;
51
        }
52
        argv[i] = null;
53
        Callback c = getCallback();
54
        if (c == null) {
55
            // XXX I18N required for cmdline?
56
            log("The User Utilities module must be installed for open-file functionality to work.", args);
57
            return 2;
58
        }
59
        int line = -1;
60
        File f = findFile (curDir, s);
61
        if (!f.exists()) {
62
            // Check if it is file:line syntax.
63
            int idx = s.lastIndexOf(':'); // NOI18N
64
            if (idx != -1) {
65
                try {
66
                    line = Integer.parseInt(s.substring(idx + 1)) - 1;
67
                    f = findFile (curDir, s.substring(0, idx));
68
                } catch (NumberFormatException e) {
69
                    // OK, leave as a filename
70
                }
71
            }
72
        }
73
        // Just make sure it was opened, then exit.
74
        boolean success = c.open(f, line, null);
75
        return success ? 0 : 1;
76
    }
77
    
38
    protected int cli(CLIHandler.Args args) {
78
    protected int cli(CLIHandler.Args args) {
39
        String[] argv = args.getArguments();
79
        String[] argv = args.getArguments();
40
        File curDir = args.getCurrentDirectory ();
80
        File curDir = args.getCurrentDirectory ();
41
        boolean wait = false;
42
        for (int i = 0; i < argv.length; i++) {
81
        for (int i = 0; i < argv.length; i++) {
43
            if (argv[i] == null) {
82
            if (argv[i] == null) {
44
                continue;
83
                continue;
45
            }
84
            }
46
            if (argv[i].equals("-open")) { // NOI18N
85
            if (argv[i].equals("--open") || argv[i].equals("-open")) { // NOI18N
47
                argv[i] = null;
86
                argv[i] = null;
48
                if (i == argv.length - 1) {
87
                if (i == argv.length - 1) {
49
                    log("Missing argument to -open", args);
88
                    log("Missing argument to --open", args);
50
                    return 2;
89
                    return 2;
51
                }
90
                }
52
                String s = argv[++i];
91
                i++;
53
                if (s == null) {
92
                while (i < argv.length && !argv[i].startsWith ("-")) {
54
                    log("Missing argument to -open", args);
93
                    int res = openFile (curDir, args, argv, i++);
55
                    return 2;
94
                    if (res != 0) {
56
                }
95
                        return res;
57
                argv[i] = null;
58
                Callback c = getCallback();
59
                if (c == null) {
60
                    // XXX I18N required for cmdline?
61
                    log("The User Utilities module must be installed for open-file functionality to work.", args);
62
                    return 2;
63
                }
64
                int line = -1;
65
                File f = new File(s);
66
                if (!f.isAbsolute()) {
67
                    f = new File(curDir, s);
68
                }
69
                if (!f.exists()) {
70
                    // Check if it is file:line syntax.
71
                    int idx = s.lastIndexOf(':'); // NOI18N
72
                    if (idx != -1) {
73
                        try {
74
                            line = Integer.parseInt(s.substring(idx + 1)) - 1;
75
                            f = new File(s.substring(0, idx));
76
                        } catch (NumberFormatException e) {
77
                            // OK, leave as a filename
78
                        }
79
                    }
96
                    }
80
                }
97
                }
81
                boolean success;
98
            } 
82
                if (wait) {
83
                    // Open it, and wait for it to be closed.
84
                    Callback.Waiter w = new Callback.Waiter() {
85
                        public synchronized void done() {
86
                            notify();
87
                        }
88
                    };
89
                    success = c.open(f, line, w);
90
                    /* XXX uncomment when implemented in module
91
                    if (success) {
92
                        try {
93
                            synchronized (w) {
94
                                w.wait();
95
                            }
96
                        } catch (InterruptedException e) {
97
                            e.printStackTrace();
98
                        }
99
                    }
100
                     */
101
                } else {
102
                    // Just make sure it was opened, then exit.
103
                    success = c.open(f, line, null);
104
                }
105
                if (!success) {
106
                    return 1;
107
                }
108
            } else if (argv[i].equals("-wait")) { // NOI18N
109
                argv[i] = null;
110
                wait = true;
111
            }
112
        }
99
        }
113
        // No problems.
100
        // No problems.
114
        return 0;
101
        return 0;
Lines 122-136 public class Handler extends CLIHandler Link Here
122
    }
109
    }
123
    
110
    
124
    protected void usage(PrintWriter w) {
111
    protected void usage(PrintWriter w) {
125
        w.println("-open FILE");
112
        w.println("Open File Module options:");
126
        w.println("  Open FILE.");
113
        w.println("  --open FILE           open FILE.");
127
        w.println("-open FILE:LINE");
114
        w.println("  --open FILE:LINE      open FILE at line LINE (starting from 1).");
128
        w.println("  Open FILE at line LINE (starting from 1).");
129
        /* XXX uncomment when implemented in module
130
        w.println("-wait -open FILE[:LINE]");
131
        w.println("  Open FILE (maybe at line LINE), and wait until it is closed before exiting.");
132
        w.println("  (Currently unimplemented.)");
133
         */
134
    }
115
    }
135
    
116
    
136
}
117
}

Return to bug 32053