Here I present a ConTeXt solution using the --arguments feature
and modes. Modes provide a
way to conditionally include parts of a document. For instance, when
printing a text book one can decide to print only the text or the
text including exercises or everything, including exercises and
hints to each exercise. Another use case is a single source file for
slides and handouts.
It's up to you what you want to mark up. Either mark up each
exercise, if you want to be able to include individual exercises, or
mark the individual difficulty levels. That way you can include all
exercises from a particular difficulty level.
\doifsomething{\env{from}}{%%
\dostepwiserecurse{\env{from}}{\env{to}}{1}{%%
\enablemode [ex-\recurselevel]}}
\starttext
\startmode [ex-1]
A very easy exercise
\startmode [clues]
Clue to exercise 1
\stopmode
\stopmode
\startmode [ex-2]
An easy exercise
\stopmode
\startmode [ex-3]
A fairly easy exercise
\startmode [clues]
Clue to exercise 3
\stopmode
\stopmode
\startmode [ex-4]
An moderate exercise
\stopmode
%% […]
\startmode [ex-10]
A very hard exercise
\startmode [clues]
Clue to exercise 10
\stopmode
\stopmode
\stoptext
Here I created some example exercises with numeric difficulty
levels. Some of the exercises have clues. Now you can include
particular exercises on the command line. This includes exercise one
and two and no clues.
context --arguments=from=1,to=2 file.tex
It renders as:

To include exercise three to ten and the clues, use:
context --arguments=from=3,to=10 --mode=clues file.tex
It renders as:

As you can see, the values of the arguments can be obtained using
\env{key}. It is also possible to directly pass arguments to
context:
context --bodyfont=pagella file.tex
The value can be obtained using \getdocumentargument{bodyfont} in
this case. But I'd recommend using --argument, since it's safer
and does not clash with already defined command line arguments.
latex \def\x{y} \input file.texfrom commandline. I'd prefer, however, such a script to generate a short "config" file, which is then\inputby your document/package/class. – mbork Sep 11 '13 at 19:25bash):latex "\def\x{y}\input{file.tex}"? – jon Sep 11 '13 at 19:54