Exemplo n.º 1
0
		public static void  Main(String[] args)
		{
			DebugCLI cli = new DebugCLI();
			
			/* attach our 'main' input method and out/err*/
			StreamWriter temp_writer;
			temp_writer = new StreamWriter(System.Console.OpenStandardError(), System.Console.Error.Encoding);
			temp_writer.AutoFlush = true;
			cli.m_err = temp_writer;
			StreamWriter temp_writer2;
			temp_writer2 = new StreamWriter(System.Console.OpenStandardOutput(), System.Console.Out.Encoding);
			temp_writer2.AutoFlush = true;
			cli.m_out = temp_writer2;

            /* iterate through the args list */
            cli.processArgs(args);

            // get the default <application.home>/projects/frameworks/*/src entries into the source path
			cli.initSourceDirectoriesList();
			
			// a big of wrangling for our keyboard input stream since its special
            StreamReader stdin = new StreamReader(System.Console.OpenStandardInput(), System.Text.Encoding.Default);

			cli.m_keyboardStream = new LineNumberReader(new StreamReader(stdin.BaseStream, stdin.CurrentEncoding));
			cli.pushStream(cli.m_keyboardStream);
			
			/* figure out $HOME and the current directory */
			String userHome = System.Environment.GetEnvironmentVariable("userprofile"); //$NON-NLS-1$
			String userDir = System.Environment.CurrentDirectory; //$NON-NLS-1$
			
			/*
			* If the current directory is not $HOME, and a .fdbinit file exists in the current directory,
			* then push it onto the stack of files to read.
			* 
			* Note, we want ./.fdbinit to be read AFTER $HOME/.fdbinit, but we push them in reverse
			* order, because they're going onto a stack.  If we push them in reverse order, then they
			* will be read in the correct order (last one pushed is the first one read).
			*/
			if (userDir != null && !userDir.Equals(userHome))
			{
				try
				{
					StreamReader sr = new StreamReader(new FileInfo(userDir + "\\" + ".fdbinit").FullName, System.Text.Encoding.Default); //$NON-NLS-1$
					cli.pushStream(new LineNumberReader(sr));
				}
				catch (FileNotFoundException)
				{
				}
			}
			
			/*
			* If a .fdbinit file exists in the $HOME directory, then push it onto the stack of files
			* to read.
			* 
			* Note, we want ./.fdbinit to be read AFTER $HOME/.fdbinit, but we push them in reverse
			* order, because they're going onto a stack.  If we push them in reverse order, then they
			* will be read in the correct order (last one pushed is the first one read).
			*/
			if (userHome != null)
			{
				try
				{
					StreamReader sr = new StreamReader(new FileInfo(userHome + "\\" + ".fdbinit").FullName, System.Text.Encoding.Default); //$NON-NLS-1$
					cli.pushStream(new LineNumberReader(sr));
				}
				catch (FileNotFoundException)
				{
				}
			}
			
			cli.execute();
		}