Skip to content

Commit 64d3e67

Browse files
committed
Add option to open help as a web page
1 parent 5a71774 commit 64d3e67

File tree

120 files changed

+363
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+363
-98
lines changed

src/main/java/org/geometrycommands/App.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import org.kohsuke.args4j.CmdLineParser;
44

5+
import java.awt.*;
56
import java.io.InputStreamReader;
67
import java.io.Reader;
78
import java.io.StringWriter;
89
import java.io.Writer;
10+
import java.net.URI;
11+
import java.net.URISyntaxException;
912
import java.util.ServiceLoader;
1013

1114
/**
@@ -64,6 +67,10 @@ public static void main(String[] args) {
6467
System.out.println("geom " + command.getName() + ": " + command.getDescription());
6568
cmdLineParser.printUsage(System.out);
6669
}
70+
else if (options.isWebHelp()) {
71+
URI uri = new URI("http://jericks.github.io/geometrycommands/commands/" + name + ".html");
72+
Desktop.getDesktop().browse(uri);
73+
}
6774
else {
6875
// If there are no errors, execute the command
6976
Reader reader = new InputStreamReader(System.in);
@@ -81,6 +88,15 @@ public static void main(String[] args) {
8188
System.out.println("geom " + command.getName() + ": " + command.getDescription());
8289
cmdLineParser.printUsage(System.out);
8390
}
91+
// Open help in a browser
92+
else if (options.isWebHelp()) {
93+
try {
94+
URI uri = new URI("http://jericks.github.io/geometrycommands/commands/" + name + ".html");
95+
Desktop.getDesktop().browse(uri);
96+
} catch(Exception ex) {
97+
System.err.println("Unable to open help in web browser!");
98+
}
99+
}
84100
else {
85101
// Oops, display the error messages to the user
86102
System.err.println(e.getMessage());

src/main/java/org/geometrycommands/Options.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public class Options {
2121
@Option(name = "--help", usage = "Print help message", required = false)
2222
private boolean help;
2323

24+
/**
25+
* The flag to print the help message
26+
*/
27+
@Option(name = "--web-help", usage = "Open help in a web browser", required = false)
28+
private boolean webHelp;
29+
2430
/**
2531
* Get the Command name
2632
* @return The Command name
@@ -52,4 +58,21 @@ public boolean isHelp() {
5258
public void setHelp(boolean help) {
5359
this.help = help;
5460
}
61+
62+
/**
63+
* Get the flag to open help in a web browser
64+
* @return The flag to open help in a web browser
65+
*/
66+
public boolean isWebHelp() {
67+
return webHelp;
68+
}
69+
70+
/**
71+
* Set the flag to open help in a web browser
72+
* @param webHelp The flag to open help in a web browser
73+
*/
74+
public void setWebHelp(boolean webHelp) {
75+
this.webHelp = webHelp;
76+
}
77+
5578
}

src/man/geom-angle.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ geom angle -g "POINT (1 1)" -o "POINT (10 10)"
1414
.PP
1515
--help : Print help message
1616
.PP
17+
--web-help : Open help in a web browser
18+
.PP

src/man/geom-arc.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ geom arc -g "POINT (100 100)" -d -a 45 -e 90 -w 50 -h 50 -p 10
2626
.PP
2727
--help : Print help message
2828
.PP
29+
--web-help : Open help in a web browser
30+
.PP

src/man/geom-arcpoly.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ geom arcpoly -g "POINT (100 100)" -a 45 -e 90 -d -p 20 -w 500 -h 500
2626
.PP
2727
--help : Print help message
2828
.PP
29+
--web-help : Open help in a web browser
30+
.PP

src/man/geom-area.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ geom area -g "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))"
1010
.PP
1111
--help : Print help message
1212
.PP
13+
--web-help : Open help in a web browser
14+
.PP

src/man/geom-asciiart.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ geom asciiart -g "POINT (10 10)"
1010
.PP
1111
--help : Print help message
1212
.PP
13+
--web-help : Open help in a web browser
14+
.PP

src/man/geom-boundary.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ geom boundary -g "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))"
1010
.PP
1111
--help : Print help message
1212
.PP
13+
--web-help : Open help in a web browser
14+
.PP

src/man/geom-buffer.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ geom buffer -g "POINT (1 1)" -d 10
2424
.PP
2525
--help : Print help message
2626
.PP
27+
--web-help : Open help in a web browser
28+
.PP

src/man/geom-centroid.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ geom centroid -g "POLYGON ((1 1, 1 10, 10 10, 10 1, 1 1))"
1010
.PP
1111
--help : Print help message
1212
.PP
13+
--web-help : Open help in a web browser
14+
.PP

0 commit comments

Comments
 (0)