(
dbname,
username_opt,
host,
port,
prompt_passwd,
never_prompt,
single_connection,
dbname_opt,
username,
version,
pgclirc,
dsn,
row_limit,
application_name,
less_chatty,
prompt,
prompt_dsn,
list_databases,
ping_database,
auto_vertical_output,
list_dsn,
warn,
ssh_tunnel: str,
init_command: str,
log_file: str,
)
| 1491 | @click.argument("dbname", default=lambda: None, envvar="PGDATABASE", nargs=1) |
| 1492 | @click.argument("username", default=lambda: None, envvar="PGUSER", nargs=1) |
| 1493 | def cli( |
| 1494 | dbname, |
| 1495 | username_opt, |
| 1496 | host, |
| 1497 | port, |
| 1498 | prompt_passwd, |
| 1499 | never_prompt, |
| 1500 | single_connection, |
| 1501 | dbname_opt, |
| 1502 | username, |
| 1503 | version, |
| 1504 | pgclirc, |
| 1505 | dsn, |
| 1506 | row_limit, |
| 1507 | application_name, |
| 1508 | less_chatty, |
| 1509 | prompt, |
| 1510 | prompt_dsn, |
| 1511 | list_databases, |
| 1512 | ping_database, |
| 1513 | auto_vertical_output, |
| 1514 | list_dsn, |
| 1515 | warn, |
| 1516 | ssh_tunnel: str, |
| 1517 | init_command: str, |
| 1518 | log_file: str, |
| 1519 | ): |
| 1520 | if version: |
| 1521 | print("Version:", __version__) |
| 1522 | sys.exit(0) |
| 1523 | |
| 1524 | config_dir = os.path.dirname(config_location()) |
| 1525 | if not os.path.exists(config_dir): |
| 1526 | os.makedirs(config_dir) |
| 1527 | |
| 1528 | # Migrate the config file from old location. |
| 1529 | config_full_path = config_location() + "config" |
| 1530 | if os.path.exists(os.path.expanduser("~/.pgclirc")): |
| 1531 | if not os.path.exists(config_full_path): |
| 1532 | shutil.move(os.path.expanduser("~/.pgclirc"), config_full_path) |
| 1533 | print("Config file (~/.pgclirc) moved to new location", config_full_path) |
| 1534 | else: |
| 1535 | print("Config file is now located at", config_full_path) |
| 1536 | print( |
| 1537 | "Please move the existing config file ~/.pgclirc to", |
| 1538 | config_full_path, |
| 1539 | ) |
| 1540 | if list_dsn: |
| 1541 | try: |
| 1542 | cfg = load_config(pgclirc, config_full_path) |
| 1543 | for alias in cfg["alias_dsn"]: |
| 1544 | click.secho(alias + " : " + cfg["alias_dsn"][alias]) |
| 1545 | sys.exit(0) |
| 1546 | except Exception: |
| 1547 | click.secho( |
| 1548 | "Invalid DSNs found in the config file. Please check the \"[alias_dsn]\" section in pgclirc.", |
| 1549 | err=True, |
| 1550 | fg="red", |
no test coverage detected