Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Command line interface
======================

.. argparse::
:module: dpdata.cli
:func: dpdata_parser
:prog: dpdata
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'sphinx.ext.intersphinx',
'numpydoc',
'm2r2',
'sphinxarg.ext',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to dpdata's documentation!
:maxdepth: 2
:caption: Contents:

cli
formats
api/api

Expand Down
25 changes: 18 additions & 7 deletions dpdata/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
from .system import System, LabeledSystem, MultiSystems


def dpdata_cli():
"""dpdata cli.
def dpdata_parser() -> argparse.ArgumentParser:
"""Returns dpdata cli parser.

Examples
--------
.. code-block:: bash

$ dpdata -iposcar POSCAR -odeepmd/npy -O data -n
Returns
-------
argparse.ArgumentParser
dpdata cli parser
"""
parser = argparse.ArgumentParser(
description="dpdata: Manipulating multiple atomic simulation data formats",
Expand All @@ -28,7 +27,19 @@ def dpdata_cli():
parser.add_argument("--type-map", "-t", type=str, nargs="+", help="type map")

parser.add_argument('--version', action='version', version='dpdata v%s' % __version__)
return parser


def dpdata_cli():
"""dpdata cli.

Examples
--------
.. code-block:: bash

$ dpdata -iposcar POSCAR -odeepmd/npy -O data -n
"""
parser = dpdata_parser()
parsed_args = parser.parse_args()
convert(**vars(parsed_args))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
'ase': ['ase'],
'amber': ['parmed'],
'pymatgen': ['pymatgen'],
'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx'],
'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx', 'sphinx-argparse'],
},
entry_points={"console_scripts": ["dpdata = dpdata.cli:dpdata_cli"]},
)
Expand Down