secretGeek / ok-bash

.ok folder profiles for bash
MIT License
89 stars 6 forks source link

Feature request: support cross-platform projects #13

Closed svenssonaxel closed 4 years ago

svenssonaxel commented 5 years ago

IIUC, ok-bash and ok-ps use the same .ok file name and there doesn't seem to be an easy way to dispatch depending on whehter ok-bash or ok-ps is in use.

Some cross-platform projects folders have different scripts and instructions depending on e.g. whether bash is available. Note that this isn't about platform/OS, but on whether bash or ps is available, since that's what will execute the commands listed in .ok.

Suggestion: Extend the syntax of the .ok file so that lines beginning with a /!([a-z])+ / prefix are recognized as being limited to that implementation of ok, e.g. bash or ps. Example:

# Comment shown using both ok-bash and ok-ps
make # Build project
!bash ./run # Run project
!ps run.ps # Run project

ok-bash would then show this menu:

# Comment shown using both ok-bash and ok-ps
1. make # Build project
2. ./run # Run project
doekman commented 5 years ago

I see your problem, but I think another solution would be better.

What if you could override the default name of the ok-file, something like this:

. /path/to/ok.sh ok_name .ok-bash

this will then set an environment variable _OK_FILE to .ok-bash. The ok-alias' argument --file would still override this when used.

Another solution would be not to have .ok files for bash and ps in the same folder. But then again, .js and .css files should be able to be in the same folder, so why not .ok files...

@secretGeek Your thoughts?

svenssonaxel commented 4 years ago

I agree that complicating the parsing as I originally proposed might not be the best.

Another option:

secretGeek commented 4 years ago

I agree that complicating the parsing as I originally proposed might not be the best.

Another option:

  • Let ok-bash by default try .ok-bash and .ok in succession.
  • Let ok-ps by default try .ok-ps and .ok in succession.

I think this is a good idea.

doekman commented 4 years ago

I think we should not try .ok-bash but try .ok-sh instead.

secretGeek commented 4 years ago

That’s the spec then, agreed.