Browse Source

Fixed changing defined attribute optionality

Yentl Van Tendeloo 7 years ago
parent
commit
2a29ed7353
1 changed files with 6 additions and 4 deletions
  1. 6 4
      bootstrap/mini_modify.alc

+ 6 - 4
bootstrap/mini_modify.alc

@@ -207,7 +207,6 @@ String function cmd_attr_del(write : Boolean, model : Element, element_name : St
 		return "Permission denied to write"!
 
 String function cmd_attr_name(write : Boolean, model : Element, element_name : String, attr_name : String, new_attr_name : String):
-	log("CHANGE ATTRIBUTE NAME")
 	if (write):
 		if (dict_in(model["model"], element_name)):
 			Element attrs
@@ -223,7 +222,6 @@ String function cmd_attr_name(write : Boolean, model : Element, element_name : S
 						optional = read_attribute(model, attr_edge, "optional")
 						model_undefine_attribute(model, element_name, attr_name)
 						model_define_attribute_ID(model, element_name, new_attr_name, optional, attrs[attr_name], attr_edge)
-						log("SUCCESS")
 						return "Success"!
 					else:
 						return "Attribute already defined: " + new_attr_name!
@@ -274,7 +272,11 @@ String function cmd_attr_optional(write : Boolean, model : Element, element_name
 					// TODO use a cleaner way of deleting the attribute
 					String attr_edge
 					attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
-					optional = read_attribute(model, attr_edge, "optional")
+					log("Was optional: " + cast_v2s(read_attribute(model, attr_edge, "optional")))
+					if (optional):
+						log("Setting to optional")
+					else:
+						log("Setting to mandatory")
 					model_undefine_attribute(model, element_name, attr_name)
 					model_define_attribute_ID(model, element_name, attr_name, optional, attrs[attr_name], attr_edge)
 					return "Success"!
@@ -514,7 +516,7 @@ Element function modify(model : Element, write : Boolean):
 		elif (cmd == "attr_type"):
 			output(cmd_attr_type(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("Type name?")))
 		elif (cmd == "attr_optional"):
-			output(cmd_attr_optional(write, model, single_input("Name?"), single_input("Attribute name?"), cast_s2b(single_input("Optional?"))))
+			output(cmd_attr_optional(write, model, single_input("Name?"), single_input("Attribute name?"), input()))
 		elif (cmd == "delete"):
 			output(cmd_delete(write, model, single_input("Name?")))
 		elif (cmd == "nice_list"):