diff --git a/doorstop/cli/commands.py b/doorstop/cli/commands.py index 6b6bd1c1..6f2ea727 100644 --- a/doorstop/cli/commands.py +++ b/doorstop/cli/commands.py @@ -177,7 +177,14 @@ def run_add(args, cwd, _, catch=True): request_next_number = _request_next_number(args) tree = _get_tree(args, cwd, request_next_number=request_next_number) document = tree.find_document(args.prefix) - + try: + if args.count > 1 and (args.link or args.text): + raise AssertionError( + "Link and Text can only be parsed when creating a single Doorstop Item!", + ) + except AssertionError as argsError: + log.error(argsError) + return False # add items to it for _ in range(args.count): item = document.add_item( @@ -186,6 +193,11 @@ def run_add(args, cwd, _, catch=True): name=args.name, reorder=args.noreorder, ) + + if args.link: + item.link(args.link) + if args.text: + item.set("text", args.text) utilities.show("added item: {} ({})".format(item.uid, item.relpath)) # Edit item if requested diff --git a/doorstop/cli/main.py b/doorstop/cli/main.py index 56e8fc47..c251fc52 100644 --- a/doorstop/cli/main.py +++ b/doorstop/cli/main.py @@ -194,6 +194,7 @@ def main(args=None): # pylint: disable=R0915 # Parse arguments args = parser.parse_args(args=args) + # Configure logging utilities.configure_logging(args.verbose) @@ -311,6 +312,17 @@ def _add(subs, shared): type=utilities.positive_int, help="number of items to create", ) + + sub.add_argument( + "--link", + help=("Doorstop Item to link this new Item to"), + ) + sub.add_argument( + "-t", + "--text", + help=("Text to write into doorstop Item at point of creation"), + ) + sub.add_argument( "--edit", action="store_true",