Question: I have a question regarding a select mysql query. Lets say that we have 2 tables

users: [ id, username ]
logs [ id, user\_id, action ]

I want to selecr all users from table users with the count(`id`) of table logs based on user\_id

I tried to do the following:

```
SELECT t1.*,count(t2.`id`) 
FROM `users` t1
LEFT JOIN `logs` t2 
ON  t1.id = t2.user_id;

```

But that only prints the users who have count logs > 0. I want to select all the users with the count of the logs.

Answer: 
Gulp doesn't offer any kind of util for that, but you can use one of the many command args parsers. I like [`yargs`](https://www.npmjs.org/package/yargs). Should be:

```js
var argv = require('yargs').argv;

gulp.task('my-task', function() {
    return gulp.src(argv.a == 1 ? options.SCSS_SOURCE : options.OTHER_SOURCE)
        .pipe(sass({style:'nested'}))
        .pipe(autoprefixer('last 10 version'))
        .pipe(concat('style.css'))
        .pipe(gulp.dest(options.SCSS_DEST));
});

```

You can also combine it with [`gulp-if`](https://github.com/robrich/gulp-if) to conditionally pipe the stream, very useful for dev vs. prod building:

```
var argv = require('yargs').argv,
    gulpif = require('gulp-if'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify');

gulp.task('my-js-task', function() {
  gulp.src('src/**/*.js')
    .pipe(concat('out.js'))
    .pipe(gulpif(argv.production, uglify()))
    .pipe(gulpif(argv.production, rename({suffix: '.min'})))
    .pipe(gulp.dest('dist/'));
});

```

And call with `gulp my-js-task` or `gulp my-js-task --production`.
And if you are using typescript (`gulpfile.ts`) then do this for `yargs` (building on @Caio Cunha's excellent answer <https://stackoverflow.com/a/23038290/1019307> and other comments above):

Install
-------

```
npm install --save-dev yargs

typings install dt~yargs --global --save

```

### `.ts` files

Add this to the .ts files:

```
import { argv } from 'yargs';

...

  let debug: boolean = argv.debug;

```

This has to be done in each .ts file individually (even the `tools/tasks/project` files that are imported into the `gulpfile.ts/js`).

Run
---

```
gulp build.dev --debug

```

Or under `npm` pass the arg through to gulp:

```
npm run build.dev -- --debug

```