Skip to content

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Feb 4, 2018

Based on the discussion in #7521, dlang/tools#292 and #7838 the conclusion was the following:

This is a simple version to get approval of the concept.
Moving over the full attributes from #7521 will be easy and can be done as a follow-up as for now this feature is undocumented.

As you might have noticed, this would also require refactoring the JsonWriter.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Auto-close Bugzilla Description
18368 -X should print all static information on stdout if no files are given

@timotheecour
Copy link
Contributor

We should keep things orthogonal: where we output json (file vs stdout) and what (with or without input files):

  • -Xf=outputfile should also print all static info to outputfile if no input files are given (same as -X)

  • outputting to stdout (eg via -X or whatever syntax is used) should behave exactly as -Xf=outputfile (except outputting to stdout) even when input files are given

  • There's a change of behavior involved: -X currently outputs json to mainfile.json;

  • Why not make things simple and use -Xf=- to mean stdout? following a common convention: https://unix.stackexchange.com/questions/16357/usage-of-dash-in-place-of-a-filename

@wilzbach
Copy link
Contributor Author

wilzbach commented Feb 4, 2018

There's a change of behavior involved: -X currently outputs json to mainfile.json;

No. dmd -X will just print the help page, but if -Xf=- makes everyone happy, I don't mind to change it do this.

-Xf=outputfile should also print all static info to outputfile if no input files are given (same as-X)

Ok. I will change to this soon.

json_info(&buf);
buf.writestring("\n");
// write to stdout for -X and -Xf=-
if (!global.params.jsonfilename || strcmp(global.params.jsonfilename, "-") == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If wanted I can split this if statement and print the manual for -X (previous behavior).

@timotheecour
Copy link
Contributor

what i meant was:
dmd -X main.d currently writes main.json so this PR introduces a change of behavior if -X were to mean stdout; hence the new syntax -Xf=- is nice because it doesn't introduce a change of behavior, and is also intuitive and standard

@wilzbach
Copy link
Contributor Author

wilzbach commented Feb 4, 2018

FYI #7838 comes with the same behavior and actually already does what this PR was trying to do, so let's better move the discussion to that PR.

@wilzbach wilzbach closed this Feb 4, 2018
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

Successfully merging this pull request may close these issues.

3 participants