ceylon / ceylon-compiler

DEPRECATED
GNU General Public License v2.0
138 stars 36 forks source link

Allow modules to install an OS-level command on the user's PATH #2111

Open quintesse opened 9 years ago

quintesse commented 9 years ago

Be able to do something like:

$ ceylon command install example/1.0.0
$ example
[example's output here]

This is closely related to the ceylon plugin tool which allows you to install extensions to the ceylon command. But instead of installing a sub-command for the main Ceylon tool it would install a completely independent script.

The way I would imagine this to work is to create/copy a *nix shell script or a Windows batch file to ~/.ceylon/osbin/mymodule that would contain something like ceylon run mymodule/1.0.0 "$@" so that the user could just type mymodule to execute the tool (assuming ~/.ceylon/osbin was added to the user's PATH of course).

We could do the same for the system level, just like we do for plugins and copy create/copy the script in /etc/ceylon/osbin (or the corresponding folders for Windows/Mac).

Now, the easiest way to implement this would be to re-use the current machinery that's already in place for dealing with plugins. For example, right now we require that you have a ceylon-example script in your script folder to create a ceylon example command. We could extend that in such a way that if you create a osbin-example script it will copy that to the user's PATH.

Thing is, it might be the easiest way, but I don't think these commands have anything to do with plugins, which might confuse people. But on the other hand I don't think it's worth it to make an entirely new system (with a new repository artifact type etc) just for 1 or 2 files that some module might include.

Possible solutions:

  1. don't care about the possible confusion
  2. rename the ceylon plugin tool to ceylon command
  3. don't re-use the plugin machinery and just create a tool (ceylon command) that can create those files on the fly (they are bound to be mostly the same anyway, just the name of the module would change)
  4. ?
luolong commented 9 years ago

How is this exactly better than aliasing bash commands?

quintesse commented 9 years ago

Literally speaking not much, but it would be a generic way to create those aliases across OSes, so instead of having to explain to people how to create a) aliases on Linux and MacOS and b) batch files on Windows and then how to add them to their startup scripts or path you can just show the command. A single cross-platform way of handling things. (You would have to set the PATH once, but a Ceylon installer could do that for you in the future) So IMHO: a lot better :)

FroMage commented 9 years ago

I'd move this to 1.3, no?

quintesse commented 9 years ago

Sure, no problem, I would like your opinion on this issue though :)

FroMage commented 9 years ago

Well, I haven't understood why we're in the business of shipping non-ceylon commands ;)

quintesse commented 9 years ago

Because we're in the business of allow people to write software? :) And this is about commands written in Ceylon after all. In no other way could a developer create a module Foo that provides a command foo to the user's system that easily. I saw this done for NPM modules and it seems extremely useful to me.

FroMage commented 9 years ago

Mmmm, I see what you mean, so it's sorta like Debian packages. Perhaps it makes sense, but I'm still not sold this isn't done better with a Debian package (well, you could argue that there are no such mechanisms for Windows, but still if I look at the nightmare that gem is, I wonder if we'd be doing the right thing following that madness)

quintesse commented 9 years ago

I would indeed say that heh :)

And honestly, making RPM packages is either doable but you'll have to distribute them yourself or you try to make RPM packages that can be officially distributed and then it suddenly becomes really hard.

I'm not really aware what madness gem has created though. Would simply copying a shell/batch file to ~/.ceylon/osbin cause the same kind of problems?

FroMage commented 9 years ago

Well, the madness is that we're using non-OS tools to install programs as opposed to expressing lib dependencies. It never works as well as OS tools.

quintesse commented 9 years ago

Perhaps, but I'm not seeing anyone creating Ceylon-based packages for applications for Debian or RedHat any time soon.

And if you do ceylon run something.not.already.installed then you're also installing a program, aren't you?

Besides, think of the cool demos you could do :)

$ ceylon command install org.example.imgconverter
$ imgconvert --add-ponies gavin.jpg gavin-with-ponies.png
FroMage commented 9 years ago

Well, but then people are going to ask for scripts run before/after installation and all that OS packages provide, so where do we draw the line?

quintesse commented 9 years ago

No no, right there, no other scripts please! hehe