Skip to content

Commit

Permalink
introduce clipboard copying
Browse files Browse the repository at this point in the history
  • Loading branch information
snigdhasjg committed Oct 3, 2023
1 parent 50c7ba8 commit 95ce561
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AWS Console Login Utility
# Installation
## Via Pip
Install via pip install.
_note this also required git to be present_
_note this also requires git to be present_

```shell
pip install git+https://github.com/snigdhasjg/aws-console.git@main
Expand Down
2 changes: 1 addition & 1 deletion aws_console/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.2.0'
5 changes: 4 additions & 1 deletion aws_console/input_output/browser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import webbrowser
import pyperclip

def open_console(url: str, argument):
if argument.stdout:
if argument.clip:
pyperclip.copy(url)
elif argument.stdout:
print(url)
else:
webbrowser.open(url)
10 changes: 7 additions & 3 deletions aws_console/input_output/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ def __arg_parser():
parser = argparse.ArgumentParser(
description="Open the AWS console in your web browser, using your AWS CLI credentials")

parser.add_argument('--profile', default=os.getenv("AWS_PROFILE", "joe-user"),
parser.add_argument('-P', '--profile', default=os.getenv("AWS_PROFILE", "joe-user"),
help="The AWS profile to create the pre-signed URL with")
parser.add_argument('--region', default=os.getenv("AWS_REGION", os.getenv("AWS_DEFAULT_REGION")),
parser.add_argument('-R', '--region', default=os.getenv("AWS_REGION", os.getenv("AWS_DEFAULT_REGION")),
help="The AWS Region to send the request to")
parser.add_argument('--stdout', action='store_true',

group1 = parser.add_mutually_exclusive_group()
group1.add_argument('--clip', action='store_true',
help="don't open the web browser, but copy the signin URL to clipboard")
group1.add_argument('--stdout', action='store_true',
help="don't open the web browser, but echo the signin URL to stdout")

return parser
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def find_version(*file_paths):
]
},
install_requires=[
'boto3'
'boto3',
'pyperclip>=1.8,<1.9'
],
author='Snigdhajyoti Ghosh',
url='https://github.com/snigdhasjg/aws-console',
Expand Down

0 comments on commit 95ce561

Please sign in to comment.