diff --git a/doorstop/cli/commands.py b/doorstop/cli/commands.py index 6b6bd1c1..ac9497c8 100644 --- a/doorstop/cli/commands.py +++ b/doorstop/cli/commands.py @@ -186,6 +186,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..3810e99f 100644 --- a/doorstop/cli/main.py +++ b/doorstop/cli/main.py @@ -194,6 +194,16 @@ def main(args=None): # pylint: disable=R0915 # Parse arguments args = parser.parse_args(args=args) + try: + if args.command == "add" and args.count > 1 and (args.link or args.text): + raise argparse.ArgumentError( + subs, + "Link and Text can only be parsed when creating a single Doorstop Item!", + ) + except argparse.ArgumentError as argsError: + log.error(argsError) + sys.exit(1) + # Configure logging utilities.configure_logging(args.verbose) @@ -311,6 +321,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",