KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > cmd > Slide


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Slide.java,v 1.5 2004/07/28 09:30:33 ib Exp $
3  * $Revision: 1.5 $
4  * $Date: 2004/07/28 09:30:33 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.cmd;
25
26
27 import org.apache.commons.httpclient.contrib.ssl.*;
28 import org.apache.commons.httpclient.protocol.Protocol;
29
30
31 /**
32  * The Slide client, the command line version for WebDAV client.
33  *
34  */

35 public class Slide {
36
37     /**
38      * The version information for the Slide client.
39      */

40     public final static String JavaDoc version = "Slide client @VERSION@";
41
42     public static void main(String JavaDoc[] args) {
43         Client client = new Client(System.in,System.out);
44         
45         String JavaDoc remoteHost = null;
46
47         //////////// BEGIN Command line arguments //////////////
48
String JavaDoc argOptions = null;
49
50         // parse arguments
51
for (int i = 0; i < args.length; i++) {
52             if (args[i].startsWith("-")) {
53                 if (argOptions != null)
54                     argOptions += args[i].substring(1);
55                 else
56                     argOptions = args[i];
57             } else {
58                 remoteHost = args[i];
59             }
60         }
61
62         // print options
63
if (argOptions != null) {
64             char option;
65             for (int i = 0; i < argOptions.length(); i++) {
66                 option = argOptions.charAt(i);
67                 switch (option) {
68                     case '-':
69                         break;
70                     case 'h':
71                         printCmdLineUsage();
72                         break;
73                     case 'v':
74                         System.out.println(version);
75                         break;
76                     case 'd':
77                         client.setDebug(Client.DEBUG_ON);
78                         break;
79                     case 's':
80                         Protocol.registerProtocol("https",
81                                                   new Protocol("https",
82                                                                new EasySSLProtocolSocketFactory(),
83                                                                443));
84                         break;
85                     default:
86                         System.exit(-1);
87                 }
88             }
89         }
90         //////////// END Command line arguments //////////////
91

92         if (remoteHost != null) {
93             client.connect(remoteHost);
94         }
95
96         client.run();
97     }
98
99     /**
100      * Print the commands options from startup
101      */

102     private static void printCmdLineUsage()
103     {
104
105         System.out.println("Usage: Slide [-vdhs] " +
106             "http://hostname[:port][/path]");
107         System.out.println
108             (" Default protocol: http, port: 80, path: /");
109         System.out.println("Options:");
110         System.out.println(" -v: Print version information.");
111         System.out.println(" -d: Debug.");
112         System.out.println(" -h: Print this help message.");
113         System.out.println(" -s: use EasySSLProtocol");
114         System.out.println(
115             "Please, email bug reports to slide-user@jakarta.apache.org");
116     }
117 }
118
119
Popular Tags