Example #1
0
		/// <summary>
		/// Class constructor.
		/// </summary>
		public ForthConsole ( )
	  	   {
			InitializeComponent ( ) ;

			// Initialization : User interface
			LocalizableUI. Register ( this ) ;
			LocalizableUI. Culture			=  Program. Settings. Language ;

			// Welcome message
			String  WelcomeString	=  String. Format (
					Resources. Localization. Forms. ForthConsole. WelcomeMessage + "\n",
					ApplicationAssembly. ApplicationTitle, ApplicationAssembly. Version,
					ApplicationAssembly. Description, ApplicationAssembly. Copyright ) ;

			Write ( WelcomeString, Color. LightSeaGreen ) ;

			// Collect commands
			Commands	=  new VMCommands ( this ) ;

			// Add our command processor
			ShellCommandInput += OnCommand ;
		    }
Example #2
0
		public override int  Run ( VMCommands  cmd, int  argc, String []  argv )
		   {
			switch ( argc )
			   {
				// "help" with no command name : displays command list with their help
				case	1 :
					foreach  ( VMCommand  ivmc  in  cmd. Commands )
						cmd. stdout ( String. Format ( "{0,-16}  {1}\n", ivmc. Name, ivmc. Help ) ) ;

					return ( 0 ) ;


				// "help" with a command name
				case	2 :
					VMCommand	vmc	=  cmd. Search ( argv [1] ) ;

					if  ( vmc  ==  null )
					   {
						cmd. stderr ( "Unknown command \"" + argv [1] + "\".\n" ) ;
						return ( -1 ) ;
					    }

					cmd. stdout ( "Usage : " + vmc. Usage + "\n" ) ;
					cmd. stdout ( "\t" + vmc. Help + "\n" ) ;

					if  ( vmc. Aliases. Length  >  0 )
						cmd. stdout ( "\tAliases : " + String. Join ( ", ", vmc. Aliases ) + ".\n" ) ;

					return ( 0 ) ;


				// "help" with too many arguments
				default :
					cmd. stderr ( "Too many arguments specified.\n" ) ;
					return ( -1 ) ;
			    }
		    }