@@ -2031,6 +2031,8 @@ public static void main(String[] args) {
20312031 new Arguments .Option ("update" , "Check for updates, and ask to install if available" ),
20322032 new Arguments .Option ("updatenow" , "Check for updates and install without asking" ),
20332033 new Arguments .StringOption ("addRepository" , "URL" , "Add an external repository URL" ),
2034+ new Arguments .StringOption ("delRepository" , "URL" , "Remove an external repository URL" ),
2035+ new Arguments .Option ("listRepositories" , "List installed external repositories." ),
20342036 });
20352037 try {
20362038 arguments .parseArguments (args );
@@ -2183,7 +2185,7 @@ public int compare(String s1, String s2) {
21832185 + repoURL + "' to "
21842186 + getPackageUserDir () + "/beauti.properties." );
21852187 } else {
2186- System .out .println ("Repository URL '" + repoURL + "' already in "
2188+ System .err .println ("Repository URL '" + repoURL + "' already in "
21872189 + getPackageUserDir () + "/beauti.properties." );
21882190 }
21892191 } catch (MalformedURLException ex ) {
@@ -2194,6 +2196,49 @@ public int compare(String s1, String s2) {
21942196 }
21952197
21962198 }
2199+
2200+ if (arguments .hasOption ("delRepository" )) {
2201+ String urlString = arguments .getStringOption ("delRepository" );
2202+ if (urlString != null ) {
2203+
2204+ URL repoURL ;
2205+
2206+ try {
2207+ repoURL = new URI (urlString ).toURL ();
2208+
2209+ List <URL > urls = getRepositoryURLs ();
2210+
2211+ int urlIdx = urls .indexOf (repoURL );
2212+ if (urlIdx < 0 ) {
2213+ System .err .println ("Repository URL '" + repoURL + "' not found in "
2214+ + getPackageUserDir () + "/beauti.properties." );
2215+ } else if (urlIdx == 0 ) {
2216+ System .err .println ("Cannot remove main repository, '" + repoURL + "'." );
2217+ } else {
2218+ urls .remove (repoURL );
2219+ saveRepositoryURLs (urls );
2220+ System .out .println ("Successfully removed repository URL '"
2221+ + repoURL + "' from "
2222+ + getPackageUserDir () + "/beauti.properties." );
2223+ }
2224+ } catch (MalformedURLException ex ){
2225+ System .err .println ("Error: malformed repository URL." );
2226+ System .exit (1 );
2227+ }
2228+ }
2229+ }
2230+
2231+ if (arguments .hasOption ("listRepositories" )) {
2232+
2233+ List <URL > urls = getRepositoryURLs ();
2234+
2235+ System .out .println ("Installed repository URLs:" );
2236+ System .out .println (urls .remove (0 ) + " (main repository, unchangeable)" );
2237+ for (URL url : urls )
2238+ System .out .println (url );
2239+
2240+ }
2241+
21972242 } catch (Exception e ) {
21982243 e .printStackTrace ();
21992244 }
0 commit comments