Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is rootShell?
- You don't really need to know as it does not exist yet. I only have completed a small part of it but I'm thinking of redoing it as right now because the current one contains about 950(approx) lines of code and I think I can shrink it down to about 500-600?
- I'm getting off-topic so here you go, rootShell will be a program similar to CMD on windows, only difference is, we will add our own custom commands. The main thing here is that it's just a console where you type commands.
- Here is the link to rootShell (Brace yourselves for stupid code.)
- ### github.com/cyniclimbu/rootShell ###
- INTO THE TECHNICAL STUFF NOW!
- We will divide the code into 3 ".rb" files.
- 1. rootShell.rb : This is the main file.
- What's it there for?
- - To system files (If it fails it will call a method from main_method and fixes if possible.)
- - Load system files
- - If all is well it will start console and you can happily type
- ----------------------------------------------------------------------------------------------------
- 2. main_methods.rb : File which will host methods that make up most things in rootShell.
- Examples include:
- - Installing rootShell
- - Checking if a system directory is deleted
- - Fixing deleted system files if possible
- - Checking if rootShell is running as administrator (Some commands would require admin privilege.)
- And so much MORE!
- ----------------------------------------------------------------------------------------------------
- 3. commands_structure : File which will host methods that make up commands for rootShell.
- I cannot explain this one with a few examples so I took a couple of screen shots to explain it.
- Open this picture in another tab. This is File No.1
- http://postimg.org/image/ojte6be3l/
- And then open this in the other tab
- http://postimg.org/image/z8tunr1yt/ This is File No.2
- Let me explain the picture now.
- Before I start I want you to know that File No.1 isn't commands_structure but File No.2 is, I uploaded File No.1 so you can see how I'm making File No.2 interact with File No.1
- How does this work?
- File No.1 -
- When executed, it opens a shell where commands are meant to be typed in and gives back appropriate result to what the user's command was requesting.
- Let's look back at File No.1 again, you see the code inside the red box?
- That's the code that will run when the user types "cd" into the shell but it's not done yet because it hasn't gave the user what they asked for and in this case we need to give them their current directory as that's what "cd" means.
- Let's go to commands_structure a.k.a File No.2 now.
- See that code inside the red box?
- That's the code that will be run when the code inside red box on File No. 1 will be run and in this case it's "cd"
- What about the blue box?
- If you didn't knew, you can run certain cmd commands from Ruby as `echo Example only` or system("echo Example only")
- And it will be executed as to how cmd would respond to it. Here it would just print out "Example only" excluding "\n" of course.
- It's easier and shorter that way. :)
- ----------------------------------------------------------------------------------------------------
- To be continued. I'm sleepy.
Advertisement
Add Comment
Please, Sign In to add comment