args = $args; $this->cwd = getcwd() . '/'; $this->read(); $this->render(); } /** * Reads the cli arguments and puts them in their place * * @params none */ public function read(){ while ( count( $this->args ) ) { $arg = array_shift( $this->args ); if ( preg_match( $this->rcss, $arg ) ) { $path = preg_match( $this->rprefix, $arg ) ? $arg : $this->cwd . $arg; $this->content .= file_get_contents( $path ); } else if ( substr( $arg, 0, 2 ) == '--' ) { $parts = explode( '=', $arg, 2 ); $name = substr( $parts[ 0 ], 2 ); $value = isset( $parts[ 1 ] ) ? $parts[ 1 ] : true; if ( $name == 'mode' ) { $this->mode = $value; } else { $this->options[ $name ] = $value === 'false' ? false : $value; } } } } /** * Outputs the compression of the content read * * @params none */ public function render(){ $this->instance = new CSSCompression(); if ( $this->mode ) { $this->instance->mode( $this->mode ); } if ( $this->options ) { $this->instance->option( $this->options ); } echo $this->instance->compress( $this->content ); } }; // Auto-initialize the cli script new Cli( $_SERVER['argv'] ); ?>