Example #1
0
        /// <summary>
        /// This will create new boards to the Json file.
        /// It will create a unique ID and timestamp for the board,
        /// just provide a name for the new board.
        /// </summary>
        /// <param name="boardName">The name of the new board.</param>
        public string createBoard(string boardName)
        {
            string created = Time.timestamp();
            string id      = Random.guid();

            Board board = new Board(id, boardName, created);

            boards.Add(board);
            json.writeFile(boards);

            return(id);
        }
Example #2
0
        /// <summary>
        /// This will sort the init parameters into a global dictionary
        /// of parameter => value
        /// </summary>
        /// <param name="args">The arguments as received from Main(args)</param>
        private void sortArgs(string[] args)
        {
            // Group the arguments by key => value(s)
            int      br = 0;
            Argument a  = new Argument {
                key = ""
            };
            //Argument profile = new Argument{key = "--user"};
            bool uname = false;
            bool upass = false;

            foreach (string arg in args)
            {
                if (arg.Equals(""))
                {
                    continue;
                }

                // Handle if it is a profile request (login ex)
                if (arg.Equals("--login") || arg.Equals("--new-profile") || uname)
                {
                    if (uname)
                    {
                        Program.user.email = arg;
                    }
                    uname = !uname;
                }
                if (arg.Equals("--password") || upass)
                {
                    string pw = Random.hashString(arg);
                    if (upass)
                    {
                        Program.user.password = pw;
                    }
                    upass = !upass;
                }

                // If the --new keyword is used, note it
                if (arg.Length >= 6 && arg.Substring(0, 6).Equals("--new-") ||
                    arg.Equals("--comment") || arg.Equals("--description"))
                {
                    isNew = true;
                }


                // If KEY in argument
                if (arg.Substring(0, 1).Equals("-"))
                {
                    // Don't add it to our list if empty key (first instance i.e)
                    if (br != 0)
                    {
                        argList.Add(a);
                    }

                    string key = arg;

                    // Clean the keys a little -
                    // Becomes a benefit elsewhere in the script,
                    // because we don't have to match as many values.
                    if (arg.Equals("--help"))
                    {
                        key = "-h";
                    }
                    if (arg.Equals("--about"))
                    {
                        key = "-a";
                    }
                    if (arg.Equals("--board"))
                    {
                        key = "-b";
                    }
                    if (arg.Equals("--list"))
                    {
                        key = "-l";
                    }
                    if (arg.Equals("--card"))
                    {
                        key = "-c";
                    }
                    if (arg.Equals("--check"))
                    {
                        key = "-p";
                    }


                    // Notice how "deep" we are in the "view"
                    if (key.Equals("-b"))
                    {
                        isBoard = true;
                    }
                    if (key.Equals("-l"))
                    {
                        isList = true;
                    }
                    if (key.Equals("-c"))
                    {
                        isCard = true;
                    }
                    if (key.Equals("-p"))
                    {
                        isChecklist = true;
                    }


                    // Initialize a new argument
                    a = new Argument {
                        key = key
                    };
                    continue;
                }


                string value = arg;

                // Correct for List indexing
                if (a.key.Equals("-b") ||
                    a.key.Equals("-l") ||
                    a.key.Equals("-c") ||
                    a.key.Equals("-p") ||
                    a.key.Equals("--point") ||
                    a.key.Equals("--cloud-save") ||
                    a.key.Equals("--cloud-get") ||
                    a.key.Equals("--del-board") ||
                    a.key.Equals("--del-list") ||
                    a.key.Equals("--del-card") ||
                    a.key.Equals("--del-check") ||
                    a.key.Equals("--del-point") ||
                    a.key.Equals("--del-comment"))
                {
                    // This is major braindead.. For some reason I can't make this check in above statement, with a &&.
                    if (Validators.isInt(arg))
                    {
                        value = indexValue(int.Parse(arg));
                    }
                }

                // If NOT KEY, but VALUE, add to the Argument value List
                a.value.Add(value);
                br++;
            }

            argList.Add(a);
        }