-def prep_project_link(args, stderr, project_exists=check_project_exists):
- # Given the user's command line arguments, return a dictionary with data
- # to create the desired project link for this Collection, or None.
- # Raises ValueError if the arguments request something impossible.
- making_collection = not (args.raw or args.stream)
- if not making_collection:
- if args.name or args.project_uuid:
- raise ValueError("Requested a Link without creating a Collection")
- return None
- link = {'tail_uuid': args.project_uuid,
- 'link_class': 'name',
- 'name': args.name}
- if not link['tail_uuid']:
- link['tail_uuid'] = arvados.api('v1').users().current().execute()['uuid']
- elif not project_exists(link['tail_uuid']):
- raise ValueError("Project {} not found".format(args.project_uuid))
- if not link['name']:
- link['name'] = "Saved at {} by {}@{}".format(
+ args = parse_arguments(arguments)
+ status = 0
+ if api_client is None:
+ api_client = arvados.api('v1')
+
+ # Determine the name to use
+ if args.name:
+ if args.stream or args.raw:
+ print >>stderr, "Cannot use --name with --stream or --raw"
+ sys.exit(1)
+ collection_name = args.name
+ else:
+ collection_name = "Saved at {} by {}@{}".format(