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

mill show - consider printing the name of the files only #4157

Open
asarkar opened this issue Dec 18, 2024 · 4 comments
Open

mill show - consider printing the name of the files only #4157

asarkar opened this issue Dec 18, 2024 · 4 comments

Comments

@asarkar
Copy link

asarkar commented Dec 18, 2024

scala% mill -s show 'foo.__.test.allSourceFiles'
====================== show foo.__.test.allSourceFiles =====================
==================================================================================================
[1/1] show
[
    "ref:v0:f3932dfa:/path/to/File1.scala",
    "ref:v0:ede72ba9:/path/to/File2.scala"
]

I don't know what these references are in front of each filename, and why are these shown. I want to use sed to process the test files, and this strange output necessitates unwanted jq mucking.

test_files=$(./mill -s show foo.__.test.allSourceFiles)
test_files=$(jq -cr 'map (split(":")[-1]) | @tsv' <<< "${test_files}")
sed -i '' '/pending/d' ${test_files}

Consider printing the name of the files unless the user specifically asks for additional details, perhaps using a --verbose/-v option.

@lefou
Copy link
Member

lefou commented Dec 18, 2024

show is more or less just dumping the JSON representations of task results. Since Task.Sources resturns Seq[PathRef], what you see is the internal representation of a PathRef.

Maybe, we could improve the JSON representation of PathRef? It would be helpful to collect the pros and cons of concrete candidates.

@lihaoyi
Copy link
Member

lihaoyi commented Dec 18, 2024

One option would be make ujson.ReadWriter[PathRef] have some threadlocal you can use to swap between "real verbose" mode and "concise but incomplete" mode, the latter used for printing out. Not sure if it's a good idea, but it could be done

@asarkar
Copy link
Author

asarkar commented Dec 18, 2024

Perhaps the PathRef class can make a difference between toString and mkString, where the latter is used by the CLI, and doesn’t have the references. Similar to how Python __str__ and __repr__ work.

@lefou
Copy link
Member

lefou commented Dec 18, 2024

Don't know how to realize it with the current typeclass approach, but from a user perspective, we'd like some --human option (or a totally new show derivate), which tries to use some more human friendly output, e.g. using yaml instead of json and more readable object representation. Would be nice, if we could make it kind of optional, so we could automatically convert the json to yaml and if we find a converter for some specific sub-tree, we use it.

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

3 participants