Skip to content

Commit

Permalink
feat(meta-css): update convert cmd
Browse files Browse the repository at this point in the history
- add --eval option to convert from string arg
  • Loading branch information
postspectacular committed Dec 22, 2023
1 parent f40800b commit d0275ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/meta-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@
"cli",
"codegen",
"component",
"combinatorial",
"compiler",
"css",
"export",
"fileformat",
"generator",
"generative",
"json",
"template",
"transpiler",
"typescript",
"ui"
],
Expand Down
10 changes: 9 additions & 1 deletion packages/meta-css/src/convert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// thing:no-export
import type { IObjectOf } from "@thi.ng/api";
import { strings, type Command } from "@thi.ng/args";
import { strings, type Command, string } from "@thi.ng/args";
import { peek } from "@thi.ng/arrays";
import { delayed } from "@thi.ng/compose";
import { assert, illegalArgs, illegalState } from "@thi.ng/errors";
Expand Down Expand Up @@ -35,6 +35,7 @@ type State = "sel" | "class" | "nest";
interface ConvertOpts extends CommonOpts {
specs: string;
include?: string[];
eval?: string;
force?: string[];
pretty: boolean;
noHeader: boolean;
Expand Down Expand Up @@ -71,8 +72,13 @@ export const CONVERT: Command<ConvertOpts, CommonOpts, AppCtx<ConvertOpts>> = {
...ARG_PRETTY,
...ARG_NO_HEADER,
...ARG_WATCH,
eval: string({
alias: "e",
desc: "eval meta stylesheet in given string (ignores other inputs & includes)",
}),
force: strings({
alias: "f",
hint: "STR",
desc: "CSS classes to force include (wildcards are supported, @-prefix will read from file)",
delim: ",",
}),
Expand All @@ -89,6 +95,8 @@ export const CONVERT: Command<ConvertOpts, CommonOpts, AppCtx<ConvertOpts>> = {
);
if (ctx.opts.watch) {
await watchInputs(ctx, specs, forceRules);
} else if (ctx.opts.eval) {
processInputs(ctx, specs, forceRules, [ctx.opts.eval]);
} else {
processInputs(
ctx,
Expand Down

0 comments on commit d0275ce

Please sign in to comment.