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 @@
import sys
import subprocess
import argparse
def popen(str):
p = subprocess.Popen(str.split(" "),
......@@ -50,17 +52,18 @@ def main(args):
out = popen("git remote")
remotes = out.strip().split("\n")
remote = False
if len(args) == 2:
remote = sys.argv[1]
remote = args.remote
# TODO -n --no-act flag
do = open_remote
if args.dry_run:
do = lambda x: print(to_http(remote_url(x)))
if not remotes:
err("No remotes")
if remote:
try:
open_remote(remote)
do(remote)
return
except Exception as e:
warn(str(e))
......@@ -69,7 +72,7 @@ def main(args):
for remote in remotes:
try:
open_remote(remote)
do(remote)
break
except Exception as e:
warn(str(e))
......@@ -77,4 +80,9 @@ def main(args):
err("All remotes failed")
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