beryllium-org / OS

Beryllium OS, a unix-like operating system for CircuitPython powered microcontrollers. (Formerly known as ljinux)
GNU General Public License v3.0
249 stars 16 forks source link

Add -p (page) argument to the cat command #8

Closed bill88t closed 2 years ago

bill88t commented 2 years ago

It would be useful to provide such functionality, in order to be able to print large files (like the Manual for example) from within ljinux

bill88t commented 2 years ago

Since we don't have any form of curses (the library) it should consider a fixed number as the page. I guess something like 20 lines or something

mdaadoun commented 2 years ago

Would it be interesting to start a "man" command ? I could try, I have the idea it could read from the Manual.txt and display the corresponding text.

Example:

man cd cd [DIR]... CHANGES TO SPECIFIED DIRECTORY

bill88t commented 2 years ago

Well that too would be great, but page sized prints would also be kinda necessary for logging. If you feel like implementing man, go ahead.

mdaadoun commented 2 years ago

I try this issue and propose a pull request to see if I understand correctly what is asked. I go for pages of hardcoded 20 lines

cat -n 4 README.md page 4 - line 60 to 80 60 line 61 line 62 line [...] 80 line

bill88t commented 2 years ago

Hmm, that's not what I meant.

An example also for hardcoded 20 lines:

cat -n README.md

1 line
2 line
...
19 line
20 line
Press any key to continue.. (user presses any key)
21 line
22 line
...
39 line
40 line
EOF

(... implies the lines in between) We could make it so it checks if the next argument after -n is a number so that it changes the count of lines per page. If it's not a number, it's the filename.

mdaadoun commented 2 years ago

Ok thanks I understand, if a number is not given then 20 lines by default. Ok I will try something.

mdaadoun commented 2 years ago

But now I think about it, cat is a concatenation command. What you are talking about isn't it the more/less commands ?

bill88t commented 2 years ago

Yea basically, I forgot those existed. This issue is a big wontfix then, as the more/less commands should be implemented.