factor out settings.py
This commit is contained in:
13
cli
13
cli
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
import os, sys, argparse
|
||||
|
||||
import pbincli.actions
|
||||
from pbincli.api import PrivateBin
|
||||
from pbincli.utils import PBinCLIException
|
||||
|
||||
|
||||
@@ -19,9 +21,6 @@ def main():
|
||||
choices=["5min", "10min", "1hour", "1day", "1week", "1month", "1year", "never"], help="expiration of paste (default: 1day)")
|
||||
send_parser.add_argument("-F", "--format", default="plaintext", action="store",
|
||||
choices=["plaintext", "syntaxhighlighting", "markdown"], help="format of text (default: plaintext)")
|
||||
send_parser.add_argument("--server", help="Set server to work with")
|
||||
send_parser.add_argument("--use-proxy", default=False, action="store_true", help="Enable using of proxy")
|
||||
send_parser.add_argument("--proxy", help="Proxy address (example: socks5://127.0.0.1:9050)")
|
||||
send_parser.add_argument("-t", "--text", help="comment in quotes. Ignored if used stdin")
|
||||
send_parser.add_argument("-p", "--password", help="password for encrypting paste")
|
||||
send_parser.add_argument("-d", "--debug", default=False, action="store_true", help="enable debug")
|
||||
@@ -49,9 +48,15 @@ def main():
|
||||
|
||||
# parse arguments
|
||||
args = parser.parse_args()
|
||||
|
||||
server = os.getenv("PRIVATEBIN_SERVER", "https://paste.i2pd.xyz/")
|
||||
proxy = os.getenv("PRIVATEBIN_PROXY")
|
||||
|
||||
api_client = PrivateBin(server, proxy=proxy)
|
||||
|
||||
if hasattr(args, "func"):
|
||||
try:
|
||||
args.func(args)
|
||||
args.func(args, api_client)
|
||||
except PBinCLIException as pe:
|
||||
print("PBinCLI error: {}".format(pe))
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user