Skip to content

Command line options cannot be extended with custom commands #1053

@JohnRiv

Description

@JohnRiv

I've developed a custom Compass command line option to be able to run CSS Lint against a project's generated CSS files (see https://github.com/Comcast/compass-csslint), but requiring it in a project's config.rb file is not sufficient enough for the command to become available. The only way I've been able to make it work is to modify /lib/compass/commands.rb and include a require statement there for the command directly.

Example Project:
https://github.com/Comcast/compass-csslint-sample
Note that it includes require 'compass-csslint' in the config.rb, but that alone is not enough. You need to modify Compass:

Update to Compass that works:
Comcast@c829eab
Note that the only change is including require 'compass-csslint' in /lib/compass/commands.rb

With that change to Compass and the compas-csslint gem installed from the repo, you should be able to run compass csslint from the command line in the root of a Compass project and see it work

A couple other things I noticed when trying to debug this myself:

If you checkout both compass-csslint-sample & compass-csslint, build the compass-csslint gem locally (gem build compass-csslint.gemspec), install the gem in a fresh rvm/gemset for the compass-csslint-sample project (gem install ../compass-csslint/compass-csslint-0.0.1.gem), and then run compass csslint from the sample project, it returns Command not found: csslint

I tried running compass install csslint from that project, but that returned No such framework: "csslint", which makes sense since it's a new command & not a framwork.

If you modify lib/compass/commands/registry.rb in Compass to add:
puts command_class.name
to the end of def register (line 6) and installed that modified version, then run compass csslint from the sample project, the last line it outputs is:
Compass::Commands::UnpackExtension
Interestingly, if I run "compass install csslint", the last line it outputs is
Compass::Commands::CSSLintProject
But it's still followed by No such framework: "csslint"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions