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`.
**Edit**

`gulp-util` is [deprecated](https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5) and should be avoid, so it's recommended to use [minimist](https://www.npmjs.com/package/minimist) instead, which `gulp-util` already used.

So I've changed some lines in my gulpfile to remove `gulp-util`:

```
var argv = require('minimist')(process.argv.slice(2));

gulp.task('styles', function() {
  return gulp.src(['src/styles/' + (argv.theme || 'main') + '.scss'])
    …
});

```

**Original**

In my project I use the following flag:

```
gulp styles --theme literature

```

Gulp offers an object `gulp.env` for that. It's deprecated in newer versions, so you must use gulp-util for that. The tasks looks like this:

```
var util = require('gulp-util');

gulp.task('styles', function() {
  return gulp.src(['src/styles/' + (util.env.theme ? util.env.theme : 'main') + '.scss'])
    .pipe(compass({
        config_file: './config.rb',
        sass   : 'src/styles',
        css    : 'dist/styles',
        style  : 'expanded'

    }))
    .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'ff 17', 'opera 12.1', 'ios 6', 'android 4'))
    .pipe(livereload(server))
    .pipe(gulp.dest('dist/styles'))
    .pipe(notify({ message: 'Styles task complete' }));
});

```

The environment setting is available during all subtasks. So I can use this flag on the watch task too:

```
gulp watch --theme literature

```

And my styles task also works.

Ciao
Ralf