Skip to content
Snippets Groups Projects
Commit 39a80200 authored by Hugo Hornquist's avatar Hugo Hornquist
Browse files

Add --dry-run.

parent 15c0b6fc
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
import sys import sys
import subprocess import subprocess
import argparse
def popen(str): def popen(str):
p = subprocess.Popen(str.split(" "), p = subprocess.Popen(str.split(" "),
...@@ -50,17 +52,18 @@ def main(args): ...@@ -50,17 +52,18 @@ def main(args):
out = popen("git remote") out = popen("git remote")
remotes = out.strip().split("\n") remotes = out.strip().split("\n")
remote = False remote = args.remote
if len(args) == 2:
remote = sys.argv[1]
# TODO -n --no-act flag do = open_remote
if args.dry_run:
do = lambda x: print(to_http(remote_url(x)))
if not remotes: if not remotes:
err("No remotes") err("No remotes")
if remote:
try: try:
open_remote(remote) do(remote)
return return
except Exception as e: except Exception as e:
warn(str(e)) warn(str(e))
...@@ -69,7 +72,7 @@ def main(args): ...@@ -69,7 +72,7 @@ def main(args):
for remote in remotes: for remote in remotes:
try: try:
open_remote(remote) do(remote)
break break
except Exception as e: except Exception as e:
warn(str(e)) warn(str(e))
...@@ -77,4 +80,9 @@ def main(args): ...@@ -77,4 +80,9 @@ def main(args):
err("All remotes failed") err("All remotes failed")
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv) parser = argparse.ArgumentParser(description='open git remotes in web browser')
parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run')
parser.add_argument('remote', action='store', nargs='?')
args = parser.parse_args()
main(args)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment