Skip to content

Commit 4dfa08b

Browse files
authored
feat: add --open flag (#11)
closes #5
1 parent eaa4022 commit 4dfa08b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Options:
5050
Clustering algorithm to be used. `optics`
5151
produces tighter clusters but is slower.
5252
Default: dbscan
53+
--open Open the generated visualization in the
54+
default browser automatically.
5355
--help Show this message and exit.
5456
```
5557

geoclustering/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@
3838
default="dbscan",
3939
help="Clustering algorithm to be used. `optics` produces tighter clusters but is slower. Default: dbscan",
4040
)
41+
@click.option(
42+
"--open",
43+
is_flag=True,
44+
help="Open the generated visualization in the default browser automatically.",
45+
)
4146
@click.argument("filename", type=click.Path(exists=True))
42-
def main(distance, size, output, filename, algorithm):
47+
def main(distance, size, output, filename, algorithm, open):
4348
df = io.read_csv_file(filename)
4449

4550
clusters = clustering.cluster_locations(
@@ -57,7 +62,8 @@ def main(distance, size, output, filename, algorithm):
5762
io.write_output_file(output, "result.geojson", encoded["geojson"])
5863
vis = io.write_visualization(output, "result.html", encoded["geojson"])
5964

60-
webbrowser.open_new_tab("file://" + str(vis.absolute()))
65+
if open:
66+
webbrowser.open_new_tab("file://" + str(vis.absolute()))
6167

6268

6369
if __name__ == "__main__":

0 commit comments

Comments
 (0)