Skip to content

Commit

Permalink
dsc sell query discogs/db with arbitrary args
Browse files Browse the repository at this point in the history
- Former release_id arg now --release_id (overrides search)
- Any number of arguments is passed as space delimited string to
  ctrl.collection.search(), which handles searching online or in DB.
- Tiny fix in error handling/reporting success when listed.
  • Loading branch information
JOJ0 committed Nov 20, 2024
1 parent e2c66a0 commit 07a4d44
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions discodos/cmd23/sell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

@click.command(name='sell')
@click.pass_obj
@click.argument("release_id", type=int)
@click.argument("query", nargs=-1)
@click.option(
"--id", "-i", "release_id",
type=int,
help="Omit search by passing a release ID with this option."
)
@click.option(
"-c", "--condition",
type=click.Choice(["M", "NM", "VG+", "VG", "G+", "G", "F", "P"],
Expand Down Expand Up @@ -63,7 +68,7 @@
prompt="Private comments",
help="Private comments about the listing."
)
def sell_cmd(helper, release_id, condition, sleeve_condition, price, status,
def sell_cmd(helper, query, release_id, condition, sleeve_condition, price, status,
location, allow_offers, comments, private_comments):
"""
List a record for sale on Discogs.
Expand All @@ -87,6 +92,11 @@ def update_user_interaction_helper(user):
log.warning("Online mode is required to list a record for sale.")
return

if not release_id:
found_release = coll_ctrl.search_release(" ".join(query))
# search_release exits program, not required to handle here.
release_id = found_release["id"]

if not price:
suggested_price = coll_ctrl.collection.fetch_price_suggestion(
release_id, condition
Expand All @@ -106,7 +116,7 @@ def update_user_interaction_helper(user):
price = click.prompt("Price", type=float)

log.info(f"Attempting to list record {release_id} for sale.")
coll_ctrl.collection.list_for_sale(
listing_successful = coll_ctrl.collection.list_for_sale(
release_id=release_id,
condition=condition,
sleeve_condition=sleeve_condition,
Expand All @@ -117,4 +127,5 @@ def update_user_interaction_helper(user):
comments=comments,
private_comments=private_comments
)
coll_ctrl.cli.p("Listed for sale.")
if listing_successful:
coll_ctrl.cli.p("Listed for sale.")

0 comments on commit 07a4d44

Please sign in to comment.