Page 1 of 2

Make a command line

Posted: Thu Mar 27, 2008 2:03 pm
by Danand
Hi alllllll!

I have done jamesmolloy's tutorial and i will now make a simple command line, or are the some other thing i most do first? If not, can somebody give me tutorials to how i make a simple command line?

Waves'
Danand

Re: Make a command line

Posted: Thu Mar 27, 2008 2:07 pm
by cyr1x
Danand wrote: .. can somebody give me tutorials to how i make a simple command line?
Do you want to write an OS which is entirely based on tutorials or what? :roll:

Posted: Thu Mar 27, 2008 2:12 pm
by Danand
I have done some code myself, but I'm not so good yet. So I'm just need some help on the way, if you understand me..

Posted: Thu Mar 27, 2008 2:20 pm
by cyr1x
Anyway,

A command line is easy. You just compare the whole string starting at the first column to the first char '\n' with an other string if there's a match then do that or that. This could already be a basic CLI and is implemented in ca. 2 hours or even less.

Posted: Thu Mar 27, 2008 2:20 pm
by t0xic
Well, you could add each key that is pressed into a buffer, and then parse that buffer (maybe run through an array of commands, looking for a match?).

@cyr1x: shouldn't even take 2 hours. (~30 minutes max for a minimal shell)

Posted: Thu Mar 27, 2008 2:26 pm
by codemastersnake
Command line processing is done using a parser. The input string scanned and tokens are formed. then these tokens are cheked and a command is created.

Learn more about parsers on internet. Try google you will get some good tutorials.

Posted: Thu Mar 27, 2008 2:29 pm
by t0xic

Code: Select all

	if (!strcmp(strtolower(input), shell_entries[i].name))
		{
			shell_entries[i].function(args);
			return;
		} 
<-- Basic parser. Come up with the struct yourself, and loop through all of the entries.

Posted: Thu Mar 27, 2008 2:36 pm
by Danand
Ok.. But first, how do i write things? I can't write now, must i have a driver to keyboard?

Posted: Thu Mar 27, 2008 2:40 pm
by t0xic
Well, if you want to have a command line, I figured that was a requirement :roll:

Posted: Thu Mar 27, 2008 2:47 pm
by codemastersnake
Danand wrote:Ok.. But first, how do i write things? I can't write now, must i have a driver to keyboard?
Yes, That is a must! By the way how far have you come through with your OS

Posted: Thu Mar 27, 2008 2:50 pm
by Danand
I have everything that are on jamesmolloy's tutorials, and now I'm trying to find things on google, in this forum and wiki.. If somebody have i nice tutorials com with it! ;)

Posted: Thu Mar 27, 2008 3:03 pm
by codemastersnake
Try http://www.osdever.net there are plenty of good tutorials.

Posted: Thu Mar 27, 2008 5:54 pm
by piranha
and now I'm trying to find things on google, in this forum and wiki.. If somebody have i nice tutorials com with it!
All the info you need on making a command line is on theses sites!

Seriously, basic command lines are easy.

-JL

Posted: Fri Mar 28, 2008 1:28 am
by xyzzy
I'll repeat what others have said: You won't get a tutorial for everything. If you do everything in your OS from tutorials, it won't be "your" OS, and when you come to something that you can't find a tutorial for you'll most likely have no hope.

Posted: Fri Mar 28, 2008 2:23 am
by JamesM
AlexExtreme wrote:I'll repeat what others have said: You won't get a tutorial for everything. If you do everything in your OS from tutorials, it won't be "your" OS, and when you come to something that you can't find a tutorial for you'll most likely have no hope.
Like now, for example!

@OP: You'll need a working keyboard driver. I am (actually) intending to put up a few more tutorials detailing moving to user mode, syscalls and writing drivers. So people like you can go a little further before you get completely stuck :twisted: