Make a command line

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Danand
Posts: 17
Joined: Mon Mar 17, 2008 4:56 pm
Contact:

Make a command line

Post 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
Sorry my english, i'm from norway.. :P

I write my own os now, DanOS. Website coming soon!
cyr1x
Member
Member
Posts: 207
Joined: Tue Aug 21, 2007 1:41 am
Location: Germany

Re: Make a command line

Post 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:
Danand
Posts: 17
Joined: Mon Mar 17, 2008 4:56 pm
Contact:

Post 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..
Sorry my english, i'm from norway.. :P

I write my own os now, DanOS. Website coming soon!
cyr1x
Member
Member
Posts: 207
Joined: Tue Aug 21, 2007 1:41 am
Location: Germany

Post 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.
Last edited by cyr1x on Thu Mar 27, 2008 2:21 pm, edited 1 time in total.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post 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)
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Post 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.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post 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.
Danand
Posts: 17
Joined: Mon Mar 17, 2008 4:56 pm
Contact:

Post by Danand »

Ok.. But first, how do i write things? I can't write now, must i have a driver to keyboard?
Sorry my english, i'm from norway.. :P

I write my own os now, DanOS. Website coming soon!
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

Well, if you want to have a command line, I figured that was a requirement :roll:
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Post 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
Danand
Posts: 17
Joined: Mon Mar 17, 2008 4:56 pm
Contact:

Post 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! ;)
Sorry my english, i'm from norway.. :P

I write my own os now, DanOS. Website coming soon!
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Post by codemastersnake »

Try http://www.osdever.net there are plenty of good tutorials.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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:
Post Reply