Closed quintesse closed 10 years ago
Also, we should add one part of this – the default profile – for the initial release, therefore allowing people to keep their regular config file completely free of any formatter settings.
Like for any Ceylon tool it should be possible to set a value for the profile argument in the config file using the section
[formattool]
and the keyprofile
.
You mean there should be a ceylon format
tool? (ATM it’s ceylon run ceylon.formatter
.)
You mean there should be a ceylon format tool?
Yes, don't you think so? :)
We don't yet officially support Ceylon-based plugins, but I think this can be "faked" for now by adding a simple shell/batch script (see ceylon plugin
) that runs ceylon run ceylon.formatter
with the arguments it was passed. That way a user can install the formatter and immediately have a ceylon format
command.
Edit: fixed typo, changed ceylon script
to ceylon plugin
Also, we should add one part of this – the default profile – for the initial release
Exactly. See #75
Yes, don't you think so? :)
Sure, it just doesn’t exist yet :)
Exactly. See #75
Yeah, I didn’t know you were going to create a second issue when I wrote that comment.
Sure, it just doesn’t exist yet :)
I think it's as simple as adding the file ./script/ceylon/formatter/ceylon-format
with the following contents:
USAGE='<arg1> <arg2>'
DESCRIPTION='Format command blah blah'
LONG_USAGE='Here you explain how to
use the format command.'
. $CEYLON_HOME/bin/ceylon-sh-setup
$CEYLON run ceylon.formatter/1.1.0 $@
and a ./script/ceylon/formatter/ceylon-format.bat
with:
set "USAGE=<arg1> <arg2>"
set "DESCRIPTION=Format command blah blah"
set "LONG_USAGE=Here you explain how to"
set "LONG_USAGE=%LONG_USAGE%use the format command."
call %CEYLON_HOME%\bin\ceylon-sh-setup.bat %*
if "%errorlevel%" == "1" (
exit /b 0
)
%CEYLON% run ceylon.formatter/1.1.0 %*
And run ceylon plugin pack ceylon.formatter/1.1.0
.
And ceylon plugin install ceylon.formatter/1.1.0
.
Disclaimer: I didn't try any of this.
Edit: fixed examples
Edit2: scripts
-> script
Alright, I finally got around to trying this out! My findings:
script
, not scripts
.bat
file is required. And screw that single-line string format. I can’t be bothered to convert that manually :D$ ceylon plugin list
ceylon-format (ceylon.formatter)
ceylon-format.bat (ceylon.formatter)
ceylon-format.bat~ (ceylon.formatter)
wtf?
ad 3) on what OS are you @lucaswerkmeister ? The file needs to be considered "executable" (meaning +x on Unix-likes and having .bat extension on Windows)
ad 4) seems the code that shows plugin scripts needs to be a bit more clever (ceylon/ceylon-compiler#1775)
The file needs to be considered "executable"
That’s what was missing, thanks! (Linux, chmod
fixed it; bat
wasn’t necessary after all.)
5) The --help output seems to truncate leading spaces from my LONG_USAGE
; without indentation, it looks a bit odd.
6) Command-line options seem to break:
ceylon format --indent="8-wide tabs" source
creates three empty directories --indent
, 8-wide
and tabs
.
ad 4) is fixed now
ad 6) can you try if ceylon format "--indent=8-wide tabs" source
works? It might just be the way the arguments are passed to the script
4) thanks!
6) doesn’t make any difference… which makes sense, because the ceylon
command never sees these quotes – they’re interpreted by the shell.
EDIT: And putting a --
before it doesn’t help either.
Ah yes, I get it, it's the script itself, like I said I didn't test any of it. Doing $CEYLON run ceylon.formatter/1.1.0 $@
is just too simplistic when dealing with arguments that can contain spaces.
Replacing $@
with "$@
(quotes individual arguments) results in only two folders: 8-wide tabs
and --indent
.
The following command actually works:
ceylon format --indentMode="8-wide tabs" source
I just forgot the name of the option facedesk
Ah :)
Yes, I too just found some articles saying that you should always quote "$@"
But why does it create directories when using wrong options? That doesn't really seem like desired behaviour, right? I mean, people make typos all the time.
I just implemented #75, and if a “profile” really means nothing more than passing "profile.``profile``"
instead of "profile.default"
to the ConfigFinder
(with the signature configOptions(profile = "default")
), then I don’t see why this has to wait for 1.2… am I missing something @quintesse?
No, I already assumed it would be easy but I didn't want to pressure you too much :) I'll re-schedule for 1.1 then
Haha, I think I was just in an “I don’t want to think about a massive formatter settings redesign while I’m rushing through ceylon.ast
” mood in ceylon/ceylon-ide-eclipse#987 :D
Great! :)
Implement the concept of "profiles". These are files that only contain formatting options. They'd be located alongside the Ceylon
config
file (so they could appear in./.ceylon
and~/.ceylon
etc) with names likeformat.default
,format.personal
,format.myproject
, etc. When the formatter is invoked without any special options it will look forformat.default
in the same way Ceylon looks for theconfig
file (looking locally first, then going up the directory hierarchy and looking in special places like the user's home folder etc). The format tool would also take an argument--profile=name
to override that default by telling it to look for the fileformat.name
instead. It should probably also be possible to say--profile=path/to/file
to point directly to a specific profile file. Like for any Ceylon tool it should be possible to set a value for the profile argument in the config file using the section[formattool]
and the keyprofile
.@lucaswerkmeister thinks it would be useful to have the profiles inherit options from parent profiles (just like the config file inherits from parent config files). I'm not so sure because I don't see tools like Eclipse implement formatting profiles like that, but if we implement this it should probably be possible to easily generate a "full profile" by telling the formatter to write all options with their current settings to a file somewhere (eg.
--write=path/to/file
).