diff --git a/helpers/parseHelper.ts b/helpers/parseHelper.ts new file mode 100644 index 0000000..c332305 --- /dev/null +++ b/helpers/parseHelper.ts @@ -0,0 +1,13 @@ +import Command, { CommandType } from "../models/command"; + +export function getCommand(commandType: CommandType) {} + +export function parser(command: string) { + // if it's just a command, then don't do anything + // return command object based on currently entered string + // then can use that command object to see if it's complete or not + // build some sort of tree for finding out the options for a user while they are typing + // go through each token, + // check if the currToken is a command + // if not, then mark it as an argument or option depending on if it has "--" flag or not +} diff --git a/models/arg.ts b/models/arg.ts new file mode 100644 index 0000000..03305dd --- /dev/null +++ b/models/arg.ts @@ -0,0 +1,7 @@ +export default class Arg { + name?: string; + description?: string; + + isOptional?: boolean; + isVariadic?: boolean; +} diff --git a/models/command.ts b/models/command.ts new file mode 100644 index 0000000..333db1c --- /dev/null +++ b/models/command.ts @@ -0,0 +1,17 @@ +import Arg from "./arg"; +import Option from "./option"; + +export enum CommandType { + git = "git", + npm = "npm", + commit = "git commit", +} + +export default class Command { + constructor( + type: CommandType, + subcommands?: Command[], + args?: Arg | Arg[], + options?: Option[] + ) {} +} diff --git a/models/option.ts b/models/option.ts new file mode 100644 index 0000000..549fd6d --- /dev/null +++ b/models/option.ts @@ -0,0 +1,13 @@ +import Arg from "./arg"; + +export default class Option { + name: string | string[]; + description?: string; + args: Arg | Arg[]; + + constructor(_name: string | string[], _desc: string, _args: Arg | Arg[]) { + this.args = _args; + this.name = _name; + this.description = _desc; + } +} diff --git a/pages/index.tsx b/pages/index.tsx index b5c57e9..7c5d2e1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,15 +1,25 @@ import Head from "next/head"; -import { useEffect, useRef } from "react"; +import { SyntheticEvent, useEffect, useRef, useState } from "react"; import { FaTh } from "react-icons/fa"; export default function Fig() { const inputRef = useRef(); + const [inputVal, setInputVal] = useState(""); useEffect(() => { inputRef.current?.focus(); }, []); + const onChangeInput = (e: SyntheticEvent) => { + const target = e.target as HTMLInputElement; + setInputVal(target.value); + + // logic for parsing and changing autocomplete options + + // logic for showing correct command icon + }; + return ( <> @@ -42,7 +52,7 @@ export default function Fig() {