Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge additions to 'doorstop add' into main branch #26

Merged
merged 1 commit into from
Jan 17, 2025
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
14 changes: 13 additions & 1 deletion doorstop/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions doorstop/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -311,6 +312,17 @@ def _add(subs, shared):
type=utilities.positive_int,
help="number of items to create",
)

sub.add_argument(
alex-harvey-dev marked this conversation as resolved.
Show resolved Hide resolved
"--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"),
alex-harvey-dev marked this conversation as resolved.
Show resolved Hide resolved
)

sub.add_argument(
"--edit",
action="store_true",
Expand Down
Loading