feat: add --open flag (#11)

closes #5
This commit is contained in:
Felix Spöttel
2022-07-01 17:08:53 +02:00
committed by GitHub
parent eaa4022b70
commit 4dfa08bbbc
2 changed files with 10 additions and 2 deletions

View File

@@ -50,6 +50,8 @@ Options:
Clustering algorithm to be used. `optics`
produces tighter clusters but is slower.
Default: dbscan
--open Open the generated visualization in the
default browser automatically.
--help Show this message and exit.
```

View File

@@ -38,8 +38,13 @@ import geoclustering.io as io
default="dbscan",
help="Clustering algorithm to be used. `optics` produces tighter clusters but is slower. Default: dbscan",
)
@click.option(
"--open",
is_flag=True,
help="Open the generated visualization in the default browser automatically.",
)
@click.argument("filename", type=click.Path(exists=True))
def main(distance, size, output, filename, algorithm):
def main(distance, size, output, filename, algorithm, open):
df = io.read_csv_file(filename)
clusters = clustering.cluster_locations(
@@ -57,7 +62,8 @@ def main(distance, size, output, filename, algorithm):
io.write_output_file(output, "result.geojson", encoded["geojson"])
vis = io.write_visualization(output, "result.html", encoded["geojson"])
webbrowser.open_new_tab("file://" + str(vis.absolute()))
if open:
webbrowser.open_new_tab("file://" + str(vis.absolute()))
if __name__ == "__main__":