TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Best way to do scoped commands in a CLI app

2 pointsby valtyover 1 year ago
I&#x27;m building a CLI and want to allow commands to be scoped to a project.<p>I&#x27;m trying to decide between:<p>A. `blah edit foo` (familiar...like brew)<p>B. `blah foo edit` (least typing...but project name could clash with command names)<p>C. `blah project foo edit` (explicit...like RESTful paths)<p>D. `blah --project=foo edit`<p>E. `blah project foo --edit`<p>Wondering if there was any guidance on this from the UNIX people. Perhaps scoping should be done using the file system. `cd path&#x2F;to&#x2F;project &amp;&amp; blah edit`. Like git does with `git --cwd=path&#x2F;to&#x2F;project`. Maybe a virtual FS could even be used. Then you wouldn&#x27;t have to continuously type in the scope with each command. Interesting thinking about how to maintain state in the terminal...thinking about how Python&#x27;s virtual env bin&#x2F;activate modifies the shell.<p>EDIT: Found an interesting guide here: https:&#x2F;&#x2F;clig.dev&#x2F;#subcommands<p>&gt; Either `noun verb` or `verb noun` ordering works, but `noun verb` seems to be more common.

1 comment

pizzafeelsrightover 1 year ago
Computer: do action, with these adjustments, in this format, to this destination, excluding these, against these targets...<p>This allows xargs against a list and also pipe to stdout or a file.