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

Fix "pc show" when an alternative configuration path is specified #33

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
28 changes: 23 additions & 5 deletions src/partcad/cli_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# Licensed under Apache License, Version 2.0.
#

import partcad as pc
import logging

from . import init


def cli_help_show(subparsers):
Expand Down Expand Up @@ -44,10 +46,26 @@ def cli_help_show(subparsers):

def cli_show(args):
if not args.config_path is None:
pc.init(args.config_path)
ctx = init(args.config_path)
else:
ctx = init()

if args.package is None:
package = "this"
else:
package = args.package

if args.assembly:
obj = pc.get_assembly(args.object, args.package)
obj = ctx.get_assembly(args.object, package)
else:
obj = ctx.get_part(args.object, package)

if obj is None:
if args.package is None:
logging.error("Object %s not found" % args.object)
else:
logging.error(
"Object %s not found in package %s" % (args.object, args.package)
)
else:
obj = pc.get_part(args.object, args.package)
obj.show()
obj.show()