You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defsave_new_meta(self, i, item_id, item_name, target_name, item_path, repo):
395
402
# Prepare metadata
396
-
item_meta=i.get('meta')
403
+
item_meta=i.get('meta', {})
397
404
item_meta.update({
398
405
"alias": item_name,
399
406
"uid": item_id,
@@ -505,6 +512,7 @@ def is_uid(self, name):
505
512
# Check if the name matches the pattern
506
513
returnbool(re.fullmatch(hex_uid_pattern, name))
507
514
515
+
508
516
defcp(self, run_args):
509
517
action_target=run_args['target']
510
518
src_item=run_args['src']
@@ -1187,6 +1195,46 @@ def rm(self, i):
1187
1195
logger.debug(f"Removing script with input: {i}")
1188
1196
returnself.parent.rm(i)
1189
1197
1198
+
defadd(self, i):
1199
+
"""
1200
+
Adds a new script to the repository.
1201
+
1202
+
Args:
1203
+
i (dict): Input dictionary with the following keys:
1204
+
- item_repo (tuple): Repository alias and UID (default: local repo).
1205
+
- item (str): Item alias and optional UID in "alias,uid" format.
1206
+
- tags (str): Comma-separated tags.
1207
+
- new_tags (str): Additional comma-separated tags to add.
1208
+
- yaml (bool): Whether to save metadata in YAML format. Defaults to JSON.
1209
+
1210
+
Returns:
1211
+
dict: Result of the operation with 'return' code and error/message if applicable.
1212
+
"""
1213
+
# Determine repository
1214
+
ifi.get('details'):
1215
+
item=i['details']
1216
+
else:
1217
+
item=i.get('item')
1218
+
ifnotitem:
1219
+
return {'return': 1, 'error': f"""No script item given to add. Please use mlc add script <repo_name>:<script_name> --tags=<script_tags> format to add a script to a given repo"""}
0 commit comments