public override IShellReturnable Execute(State state, List <Tuple <int, string, Shell.Types.IShellData> > args) { var indexable = args.First().Item3; var index = (Types.Number)args.Skip(1).First().Item3; var value = args.Last().Item3; Shell.Types.Array arr = (Shell.Types.Array)indexable; if (indexable is Shell.Types.Property prop) { arr = (Shell.Types.Array)prop.Value; } if (!index.isInt) { Console.WriteLine("Index must be an integer value!"); return(new Shell.Types.Null()); } if (arr.ListIndices().Contains(index) || index.integerValue == arr.Count().integerValue) { arr.Insert(index, value); if (indexable is Shell.Types.Property prop1) { prop1.Value = new Shell.Types.Array(arr.ListValues()); } } else { Console.WriteLine("Invalid index!"); } return(new Shell.Types.Null()); }
public override IShellReturnable Execute(State state, List <Tuple <int, string, IShellData> > args) { var path = args.First().Item3; var system = state.Namespaces.Get(typeof(Shell.Library.System).Name); var arr = (Shell.Types.Property)system.Get("Path"); var origarr = (Shell.Types.Array)arr.Value; var arrPath = new Shell.Types.Array(origarr.ListValues()); if (path is Shell.Types.String strPath) { if (new DirectoryInfo(strPath.contents).Exists) { arrPath.Insert(arrPath.Count(), strPath); arr.Value = new Shell.Types.Array(arrPath.ListValues()); } } return(new Shell.Types.None()); }