Skip to content

Commit

Permalink
Merge pull request #31 from jimisola/feature/add_version
Browse files Browse the repository at this point in the history
Add version to command line and user agent string
  • Loading branch information
hamnis authored Oct 29, 2023
2 parents 0a5cee2 + c31a131 commit ba74b03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/maven_artifact/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import textwrap
from importlib.metadata import version
from maven_artifact.artifact import Artifact

try:
Expand Down Expand Up @@ -58,6 +59,13 @@ def _split_lines(self, text, width):
class MainCommand:
def _get_arguments(self):
parser = argparse.ArgumentParser(formatter_class=WrappedNewlineFormatter, epilog=__epilog__)
parser.add_argument(
"-V",
"--version",
action="version",
version=version("maven-artifact"),
)

parser.add_argument(
"maven_coordinate",
help="""
Expand Down
9 changes: 8 additions & 1 deletion src/maven_artifact/requestor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import base64
import requests
from importlib.metadata import version

from maven_artifact.utils import Utils

Expand All @@ -10,7 +11,13 @@ def __init__(self, msg):


class Requestor(object):
def __init__(self, username=None, password=None, token=None, user_agent="Maven Artifact Downloader/1.0"):
def __init__(
self,
username=None,
password=None,
token=None,
user_agent=f"Maven Artifact Downloader/{version('maven-artifact')}",
):
self.user_agent = user_agent
self.username = username
self.password = password
Expand Down

0 comments on commit ba74b03

Please sign in to comment.