add commmnad line options
This commit is contained in:
@@ -20,6 +20,7 @@ from progress import Progress
|
||||
from progress.bar import Bar
|
||||
from typing import Optional, Any
|
||||
from typing_extensions import Self
|
||||
from argparse import ArgumentParser, Action
|
||||
|
||||
from .config import load_configuration, Config
|
||||
|
||||
@@ -117,13 +118,16 @@ class XferProgress:
|
||||
|
||||
class JpacrepoClient:
|
||||
|
||||
def __init__(self, config: Config):
|
||||
def __init__(self, config: Config, **kwargs):
|
||||
self.config: Config = config
|
||||
self.token: Optional[TokenResponse] = None
|
||||
self.provider_config: ProviderConfig = fetch_provider_config(self.config.auth_server_url)
|
||||
self.token_expiry: Optional[int] = None
|
||||
self.cond = Condition()
|
||||
self.thread: Optional[Thread] = None
|
||||
self.verbose: bool = kwargs.get('verbose', False)
|
||||
self.http2: bool = kwargs.get('http2', False)
|
||||
self.http3: bool = kwargs.get('http3', False)
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
return self
|
||||
@@ -276,8 +280,12 @@ class JpacrepoClient:
|
||||
|
||||
curl.setopt(pycurl.XFERINFOFUNCTION, progress_callback)
|
||||
curl.setopt(pycurl.NOPROGRESS, False)
|
||||
curl.setopt(pycurl.VERBOSE, False)
|
||||
curl.setopt(pycurl.VERBOSE, self.verbose)
|
||||
curl.setopt(pycurl.CAINFO, certifi.where())
|
||||
if self.http2:
|
||||
curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_2)
|
||||
if self.http3:
|
||||
curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_3)
|
||||
|
||||
with open(str(file_path), 'rb') as file:
|
||||
curl.setopt(pycurl.READDATA, file)
|
||||
@@ -288,8 +296,25 @@ class JpacrepoClient:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = ArgumentParser(
|
||||
prog='jpacrepo-uploader',
|
||||
description='CLI utility',
|
||||
epilog='Text at the bottom of help')
|
||||
parser.add_argument('-v', '--verbose',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Enable verbose output")
|
||||
parser.add_argument('-2', '--http2',
|
||||
default=True,
|
||||
action='store_true',
|
||||
help="Enable HTTP/2 protocol")
|
||||
parser.add_argument('-3', '--http3',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Enable HTTP/3 protocol")
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(encoding='utf-8', level=logging.INFO)
|
||||
with JpacrepoClient(load_configuration()) as client:
|
||||
with JpacrepoClient(load_configuration(), **args.__dict__) as client:
|
||||
client.authenticate()
|
||||
files = client.packages_to_upload()
|
||||
if len(files):
|
||||
|
Reference in New Issue
Block a user