Added source command

This commit is contained in:
Ronnie 2024-11-20 22:17:14 -05:00
parent 9b2b005893
commit e0acee0d16
3 changed files with 27 additions and 1 deletions

View file

@ -3,6 +3,7 @@ const helpCommand = () => [
<strong className="text-yellow-400">📖 Help Menu:</strong> <strong className="text-yellow-400">📖 Help Menu:</strong>
<ul className="mt-2 space-y-1"> <ul className="mt-2 space-y-1">
<li>🆘 <strong className="text-green-400">help</strong>: Display this help menu.</li> <li>🆘 <strong className="text-green-400">help</strong>: Display this help menu.</li>
<li>📄 <strong className="text-green-400">source</strong>: View the source code of this terminal.</li>
<li>📡 <strong className="text-green-400">socials</strong>: View my social links.</li> <li>📡 <strong className="text-green-400">socials</strong>: View my social links.</li>
<li>🌐 <strong className="text-green-400">selfhosted</strong>: View what I self host in my homelab.</li> <li>🌐 <strong className="text-green-400">selfhosted</strong>: View what I self host in my homelab.</li>
<li> <strong className="text-green-400">exit</strong>: Close the terminal (browser tab).</li> <li> <strong className="text-green-400">exit</strong>: Close the terminal (browser tab).</li>

View file

@ -0,0 +1,23 @@
import dynamic from "next/dynamic";
const FaGithub = dynamic(() => import("react-icons/fa6").then((mod) => mod.FaGithub), { ssr: false });
const sourceCommand = () => [
<div key="source">
<strong className="text-yellow-400">📄 Terminal Source Code:</strong>
<div className="text-white flex items-center mt-2">
<FaGithub className="text-gray-400 mr-2"/>
GitHub:{" "}
<a
href="https://github.com/Ronniie/ronniie.dev"
target="_blank"
rel="noopener noreferrer"
className="underline"
>
Ronniie/ronniie.dev
</a>
</div>
</div>,
];
export default sourceCommand;

View file

@ -6,6 +6,7 @@ import socialsCommand from "../app/commands/socials";
import selfhostedCommand from "../app/commands/selfhosted"; import selfhostedCommand from "../app/commands/selfhosted";
import exitCommand from "../app/commands/exit"; import exitCommand from "../app/commands/exit";
import unknownCommand from "../app/commands/unknown"; import unknownCommand from "../app/commands/unknown";
import sourceCommand from "../app/commands/source";
const Terminal: React.FC = () => { const Terminal: React.FC = () => {
const [input, setInput] = useState(""); const [input, setInput] = useState("");
@ -20,7 +21,7 @@ const Terminal: React.FC = () => {
const terminalEndRef = useRef<HTMLDivElement>(null); const terminalEndRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const commandsList = ["help", "socials", "exit", "selfhosted"]; const commandsList = ["help", "socials", "exit", "selfhosted", "source"];
const handleInput = (e: React.FormEvent<HTMLFormElement>) => { const handleInput = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); e.preventDefault();
@ -42,6 +43,7 @@ const Terminal: React.FC = () => {
socials: socialsCommand, socials: socialsCommand,
exit: () => exitCommand(setInputDisabled, setOutput), // Pass control functions exit: () => exitCommand(setInputDisabled, setOutput), // Pass control functions
selfhosted: selfhostedCommand, selfhosted: selfhostedCommand,
source: sourceCommand,
}; };
const commandOutput = const commandOutput =