Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Add additional params to add to support text and links
  • Loading branch information
alex-harvey-dev committed Jan 16, 2025
1 parent 883bcd3 commit 6941ee9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doorstop/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions doorstop/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 6941ee9

Please sign in to comment.