Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to allow duplicate tasks #47

Closed
MadBomber opened this issue Jul 2, 2022 · 7 comments
Closed

Add setting to allow duplicate tasks #47

MadBomber opened this issue Jul 2, 2022 · 7 comments

Comments

@MadBomber
Copy link

Why would duplicate tasks be an interesting thing? Well, I'll tell you. I work on many projects at the same time. Each project has both common and specific needs with regard to tasks so I created the CLI utility "justprep" as a pre-processor to add the ability to include common content and add modularization to my taskfiles. When you do that, you then have the ability to include a common Runfile with its tasks into a project specific Runfile which may over-ride one or more of those common tasks.

So by definition, you could warn about duplicates but not fail. That last task defined in the Runfile should be the one that gets executed.

@TekWizely
Copy link
Owner

Greetings!

I can't tell you how happy it makes me that you've already tested the new Include feature so soon after merging it and before even getting it into a release or even announcing it !

I can definitely see the value in supporting the ability to override commands in some use cases.

I'll want to grind on this a bit and decide if there are case that don't make sense. For example, I still think it's an error if you try to define a command multiple times within the same Runfile.

I'll see if I can get a PR started to allow duplicate commands as long as they are defined in different files.

Last-command-wins is likely the easiest way to go, so I'll assume that for now.

I'll cc you on the PR and we go from there - Thanks again !

-TW

@MadBomber
Copy link
Author

It sounds like you have already added an ability to include other files into run. If so, then that means I can scrap my support_run branch in my justprep preprocessor and I had so much fun playing with it.

During my testing I got this error:

run: 5.8: expecting TokenNewline ('\n')

which does not make sense to me. What does it mean?

Dewayne
o-*

@TekWizely
Copy link
Owner

It sounds like you have already added an ability to include other files into run

LOL I actually thought you were referring to my newly-added include functionality ( #44 ), which landed in the main branch the day before you starred the repo and created this ticket :)

Do feel free to build from the main branch and test the include functionality. I'd love to get some more feedback on it.

I am going to hold off on generating the next release until I deal with this duplicate command issue, as I consider it a missed bug that should have been addressed at the time include support was added.

I also found a couple of other missed places where I need to now include the Runfile as part of error messaging.

@TekWizely
Copy link
Owner

run: 5.8: expecting TokenNewline ('\n')

I'd have to see the Runfile content in and around line 5, but a quick guess is you have an error in a doc-string on line 5.

On the off chance that line 5 col 8 is the eof (ie. maybe the end of a command script), try adding a trailing newline.

@MadBomber
Copy link
Author

That specific test I was doing was with by justprep support_run branch. Its likely that the Runfile did not have a task defined only badly formed include statements to test my error codes.

BTW justprep also supports what I call a Fake Module Convention that also works with run as is... if you already know this pattern forgive me for talking too much.

Consider this Runfile

# justprep/test/Runfile

module_aaa := "modules/aaa.run"
module_bbb := "modules/bbb.run"

EXPORT module_aaa, module_bbb

##
# Say hi
hello:
  echo "Hello World"

##
# List all tasks including the modules
list_all:
  run list
  run aaa
  run bbb

##
# Module aaa
aaa:
  run -r ${module_aaa} ${@}

##
# Module bbb
bbb:
  run -r ${module_bbb} ${@}

and two others aaa.run and bbb.run both in a modules directory.

# .../modules/aaa.run

##
# Module aaa magic
magic:
  echo 'Do you believe in Magic?'

##
# Do something magical in aaa
xyzzy:
  echo "Magic from aaa ..."
  echo "... watch me pull a ${1} out of my hat."

... and ...

# .../modules/bbb.run

##
# Module bbb magic
magic:
  echo 'Do you believe in Magic?'

##
# Do something magical in bbb
xyzzy:
  echo "Magic from bbb ..."
  echo "... watch me pull a ${1} out of my hat."

Here is a console session using those three files:

13:51:20 3.1.2p20 support_run s5:test $ run
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/Runfile

Commands:
  list        (builtin) List available commands
  help        (builtin) Show help for a command
  version     (builtin) Show run version
  hello       Say hi
  list_all    List all tasks including the modules
  aaa         Module aaa
  bbb         Module bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:30 3.1.2p20 support_run s5:test $ run list_all
Commands:
  list        (builtin) List available commands
  help        (builtin) Show help for a command
  version     (builtin) Show run version
  hello       Say hi
  list_all    List all tasks including the modules
  aaa         Module aaa
  bbb         Module bbb
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/aaa.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module aaa magic
  xyzzy      Do something magical in aaa

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/bbb.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module bbb magic
  xyzzy      Do something magical in bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:41 3.1.2p20 support_run s5:test $ run aaa
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/aaa.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module aaa magic
  xyzzy      Do something magical in aaa

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:45 3.1.2p20 support_run s5:test $ run bbb
using runfile: /Users/dewayne/Documents/sandbox/git_repos/madbomber/justprep/working/support_run/test/modules/bbb.run

Commands:
  list       (builtin) List available commands
  help       (builtin) Show help for a command
  version    (builtin) Show run version
  magic      Module bbb magic
  xyzzy      Do something magical in bbb

Usage:
       run <command> [option ...]
          (run <command>)
  or   run help <command>
          (show help for <command>)

see 'run --help' for more information
13:51:52 3.1.2p20 support_run s5:test $ run aaa magic
Do you believe in Magic?
13:51:58 3.1.2p20 support_run s5:test $ run bbb magic
Do you believe in Magic?
13:52:04 3.1.2p20 support_run s5:test $ run aaa xyzzy rabbit
Magic from aaa ...
... watch me pull a rabbit out of my hat.
13:52:14 3.1.2p20 support_run s5:test $ run bbb xyzzy dinosaur
Magic from bbb ...
... watch me pull a dinosaur out of my hat.
13:52:33 3.1.2p20 support_run s5:test $

What I do in justprep is to turn a line that looks like this ...

module aaa := "modules/aaa.run

into lines that look like this ...

module_aaa := "modules/aaa.run
EXPORT module_aaa

##
# Module aaa
aaa:
  run -r ${module_aaa} ${@}

@MadBomber
Copy link
Author

I've abandoned the support_run branch in my justprep CLI utility since you are so close to releasing your own... but please consider that Fake Module Convention as a possible feature for the next release.

@TekWizely
Copy link
Owner

but please consider that Fake Module Convention as a possible feature for the next release.

I created #50 as a place to continue the Module conversation....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants