コード例 #1
0
        /////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// processes commands to extract tokens and secrets
        /// </summary>
        /// <param name="cmds"></param>
        /// <returns></returns>
        static void ProcessCmds( CmdLineParams cmds )
        {
            // ******
            var fileList = new List<string> { };
            var solutionFldr = string.Empty;
            var projectFldr = string.Empty;

            // ******
            for( int i = 0; i < cmds.Count; i += 1 ) {
                string cmd;
                string value;
                bool isCmd = cmds.GetCommand( i, out cmd, out value );

                // ******
                if( !isCmd ) {
                    //
                    // the file to process
                    //
                    var fn = FixFilePath( value );
                    if( !string.IsNullOrWhiteSpace( fn ) ) {
                        fileList.Add( fn );
                    }
                }
                else {
                    switch( cmd.ToLower() ) {
                        case "p":
                        case "project":
                            break;

                        case "s":
                        case "solution":
                            break;

                        case "w":
                        case "watch":
                            new Watcher( value, WatcherFileExts ).Run();
                            Environment.Exit( 0 );
                            break;

                        default:
                            Die( $"error: unknown command \"/{cmd}:{value}\"" );
                            break;
                    }
                }
            }

            // ******
            if( 0 == fileList.Count ) {
                Die( "error: no file name provided" );
            }
            else if( fileList.Count > 1 ) {
                Die( "error: more than one file name provided" );
            }
            else {
                var filePath = fileList.First();
                if( !File.Exists( filePath ) ) {
                    Die( $"error: could not locate file \"{filePath}\"" );
                }

                //	// ******
                //	var dataFilePath = GetDataFilePath( "Typescript\\raytracer.ts" );
                //	var runner = new Runner( dataFilePath ) { };
                //	Assert.NotNull( runner );
                //
                //	string result;
                //	string outExt;
                //	runner.Generate( out result, out outExt );
                //	Assert.True( TestNormalizeString( result ).StartsWith( "varVector=(function(){" ) );

                try {
                    var runner = new Runner( filePath ) { };

                    string result;
                    string outExt;
                    runner.Generate( true, out result, out outExt );
                }
                catch( Exception ex ) {
                    throw;
                }
            }

            // ******
            return;
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////////////////////
        //
        //
        //
        /////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// processes commands to extract tokens and secrets
        /// </summary>
        /// <param name="cmds"></param>
        /// <returns></returns>
        static void PreProcessCmds( CmdLineParams cmds )
        {
            // ******
            for( int i = 0; i < cmds.Count; /* incrementing counter handled below */ ) {
                string cmd;
                string value;
                bool isCmd = cmds.GetCommand( i, out cmd, out value );

                // ******
                bool cmdHandled = true;
                switch( cmd.ToLower() ) {
                    case "watchexts":
                        SetWatcherFileExts( value );
                        break;

                    default:
                        cmdHandled = false;
                        break;
                }

                // ******
                if( cmdHandled ) {
                    //
                    // remove the command we processed
                    //
                    cmds.Remove( i );
                }
                else {
                    //
                    // next command
                    //
                    i++;
                }
            }

            // ******
            return;
        }