Skip to content

Commit

Permalink
Merge pull request #18 from davidkastner/new-cli-welcome
Browse files Browse the repository at this point in the history
Improved the CLI welcome
davidkastner authored Jan 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9161ea7 + 23f9c1c commit 2dbf944
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions pyef/cli.py
Original file line number Diff line number Diff line change
@@ -3,12 +3,37 @@
import pyef
import click

def welcome():
"""Print first to welcome the user while it waits to load the modules"""

print("\n ╔═══════════════════════════╗")
print(" ║ .-----------------------. ║")
print(" ║ | ┌──────┐ | ║")
print(" ║ | │ ┌───┘ | ║")
print(" ║ | │ └───┐ | ║")
print(" ║ | │ ┌───┘ | ║")
print(" ║ | │ ├┬┬┬┐ | ║")
print(" ║ | └──┴┴┴┴┘ | ║")
print(" ║ | | ║")
print(" ║ | WELCOME TO PYEF | ║")
print(" ║ '-----------------------' ║")
print(" ╚═══════════════════════════╝\n")

print("Default programmed actions for the pyEF package.")
print("GitHub: https://github.com/davidkastner/pyef")
print("Documentation: https://pyef.readthedocs.io")
print("• Command for electric field analysis: pyef ef --run")
print("• Command for electrostatic analysis: pyef esp --run\n")

# Welcome even if no flags
welcome()

@click.group()
def cli():
"""pyEF Command-line Interface."""
welcome_message()
"""CLI entry point"""
pass

@click.command()
@cli.command()
@click.option("--run", is_flag=True, help="Analyze electric fields.")
def ef(run):
"""Analyzes electric fields"""
@@ -26,7 +51,7 @@ def ef(run):
metal_indices = [int(metal.strip()) for metal in metal_indices.split(",")]
pyef.run.main(jobs, geom_flag, esp_flag, metal_indices)

@click.command()
@cli.command()
@click.option("--run", is_flag=True, help="Perform an action")
def esp(run):
"""Analyzes electrostatic potential"""
@@ -43,18 +68,5 @@ def esp(run):
metal_indices = [int(metal.strip()) for metal in metal_indices.split(",")]
pyef.run.main(jobs, geom_flag, esp_flag, metal_indices)

def welcome_message():
print("\n.-------------------------.")
print("| WELCOME TO THE pyEF CLI |")
print(".-------------------------.")
print("Default programmed actions for the pyEF package.")
print("GitHub: https://github.com/davidkastner/pyef")
print("Documentation: https://pyef.readthedocs.io")
print("Command for electric field analysis: pyef ef --run")
print("Command for electrostatic analysis: pyef esp --run\n")

cli.add_command(ef)
cli.add_command(esp)

if __name__ == '__main__':
cli()

0 comments on commit 2dbf944

Please sign in to comment.