Compare commits

..

2 Commits

Author SHA1 Message Date
b1ek 0d55e924be
register commands, update styles 2023-03-16 00:40:02 +10:00
b1ek d76b8db1a0
ls and skills commands 2023-03-16 00:38:46 +10:00
7 changed files with 84 additions and 13 deletions

View File

@ -7,7 +7,7 @@ div#resume_js_app {
font-family: monospace; font-family: monospace;
box-shadow: 0 2px 1px #303030A0; box-shadow: 0 2px 1px #303030A0;
color: #e1e1e1 !important; color: #e1e1e1 !important;
padding: 2px; padding: 8px 2px;
transition: 150ms ease; transition: 150ms ease;
} }
div#resume_js_app:hover { div#resume_js_app:hover {

View File

@ -15,7 +15,8 @@ export class Console extends React.Component {
theme: { theme: {
background: '#212121', background: '#212121',
brightGreen: '#15a179' brightGreen: '#15a179'
} },
convertEol: true
}} }}
/> />
</div>; </div>;

View File

@ -9,9 +9,9 @@ const fs = require('../fs');
module.exports = (argv, terminal) => { module.exports = (argv, terminal) => {
if (argv.indexOf('--help') != -1) { if (argv.indexOf('--help') != -1) {
terminal.writeln(`Usage: ${argv[0]} [files] [-n]`); terminal.writeln(`Usage: ${argv[0]} [files] [-n]`);
terminal.writeln(' -n --number: show lines numbers'); terminal.writeln(' -n --number show lines numbers');
terminal.writeln(' --help: show this help'); terminal.writeln(' --help show this help');
terminal.writeln('Reads file into stdout'); terminal.writeln('Read files into stdout');
return; return;
} }
const numbers = (argv.indexOf('-n') != -1) || (argv.indexOf('--number') != -1); const numbers = (argv.indexOf('-n') != -1) || (argv.indexOf('--number') != -1);
@ -20,11 +20,16 @@ module.exports = (argv, terminal) => {
files.shift(); files.shift();
files.forEach(file => { files.forEach(file => {
const lines = fs.readFileSync(file).toString().split('\n'); const lines = fs.readFileSync(file).toString().split('\n');
let i = 1;
lines.forEach(line => { if (numbers) {
if (numbers) terminal.write('\033[35m' + i + ' |\033[0m '); lines.forEach((line, i) => {
terminal.writeln(line); terminal.write('\033[35m' + i + ' |\033[0m ');
i++; })
}) } else {
terminal.write(file);
/// print % if no newline at eof
if (lines[lines.length - 1] != '')
terminal.write('\033[30;47m%\033[0m\n');
}
}) })
} }

View File

@ -2,7 +2,9 @@ let cmds = {
'cat': require('./cat'), 'cat': require('./cat'),
'cmds': require('./cmds'), 'cmds': require('./cmds'),
'cmdls': require('./cmds'), 'cmdls': require('./cmds'),
'help': require('./cmds') 'help': require('./cmds'),
'ls': require('./ls'),
'skills': require('./skills')
}; };
module.exports = cmds; module.exports = cmds;

View File

@ -0,0 +1,60 @@
const { Terminal } = require('xterm');
const fs = require('../fs');
/**
*
* @param {string[]} argv
* @param {Terminal} terminal
*/
module.exports = (argv, terminal) => {
if (argv.indexOf('--help') != -1) {
terminal.writeln(`Usage: ${argv[0]} [dirs] [-a|--all] [-l]`);
terminal.writeln('Lists files in directories');
terminal.writeln(' -a --all List all files (including those who start with .)');
terminal.writeln(' -l Use long listing format');
return;
}
const has_arg = (arg) => {return argv.indexOf(arg) != -1};
let directories = [...argv];
const all = (has_arg('-a') || has_arg('--all'));
const long_format = has_arg('-l');
directories.shift();
// remove .* files if -a not specified
if (!all)
directories = directories.filter(x => x.startsWith('.'));
// remove arguments
directories = directories.filter(x => !x.startsWith('-'));
if (directories.length == 0) directories = ['.'];
// remove dublicates
directories = [...new Set(directories)];
directories.forEach((dir, i) => {
if (directories.length != 1) {
terminal.writeln(dir + ':');
terminal.writeln('');
}
let files = fs.readdirSync(dir);
files.forEach((file, i) => {
if (!fs.accessSync(file, fs.constants.X_OK))
terminal.write('\033[1;32m');
if (fs.accessSync(file, fs.constants.R_OK))
terminal.write('\033[35m');
terminal.write(file + '\033[0m ');
if ((i+1) % 5 == 0)
terminal.writeln('');
});
terminal.writeln('');
})
}

View File

@ -0,0 +1,3 @@
module.exports = (argv, terminal) => {
terminal.write('uwu\nowo\n');
}

View File

@ -4,7 +4,7 @@ div#resume_js_app {
background: #212121; background: #212121;
border: 1px solid #e1e1e1; border: 1px solid #e1e1e1;
border-radius: 6px; border-radius: 6px;
padding: 2px; padding: 8px 2px;
font-family: monospace; font-family: monospace;
transition: all .15s; transition: all .15s;
box-shadow: 0 2px 1px #303030a0; box-shadow: 0 2px 1px #303030a0;