-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mfs list command api return types #5026
Comments
This is being addressed at the moment through the following PRs. ipfs-inactive/js-ipfs-http-client#776 However, the actual http api will still return |
Hmmm, looking at the API docs, which predate the That said, it is super odd that some commands output strings for file types ( |
Is |
I talked with @whyrusleeping on IRC about the fact that
@whyrusleeping, can fill in anything about either of the above points? ^
I think that’s a much better name, but the @whyrusleeping also suggested that, while it might be hard to change them, it’s still better to do so now than later if we think it’s worthwhile. So maybe this is a good opportunity to align all the places in the API where we talk about file node types?
The endpoints in question:
Hope I’m not hijacking and expanding this too much. |
I'm sure this is possible with Go too, but languages with type systems that I've worked with before have hints you can give to their JSON marshallers/unmarshallers as to how to handle missing/null/empty values if you don't want to use different types for endpoints with more concise output - for example whether to omit them if null or empty while marshalling or to set to a default value when unmarshalling, etc.
Having the CLI tools mimic existing familiar Unix commands is a great design goal as it's instantly familiar for new users but I think our APIs and their arguments should have descriptive names as since code is read a lot more than it is written, being self documenting is more useful than being quick to type.
Having magic numbers and occasionally invalid/inconsistent magic numbers usually results in a poor developer experience. Obviously internally you can go to town but at system boundaries like APIs, strings, while slightly more inefficient, are much easier to grok.
I have a strong preference for 3i in your suggestions (e.g.
Not at all, I think this is a very useful discussion. Thanks for reviewing all the UnixFS related endpoints, I hadn't even noticed the difference between |
I totally agree on this from a philosophical perspective. To be clear, my point was more practical: the whole API infrastructure in Go is built on a system that takes a command definition and makes it available over multiple protocols. It doesn’t provide a facility for marking an option as only being available on one transport (unless I’m missing something). It could always be built! But basically, asking for (Additionally, our terribly inconsistent and poorly updated docs [which, yes, I am working on!] have one thing going for them, which is: if the docs don’t make sense, you can always type
|
Hey all, sorry for the confusion. I have been known to write code without thinking hard enough about its consequences, and this is one of those places. As usual, @Mr0grog's comments are on point. There are a couple ways forward here:
We can add |
That's much more useful. ipfs/kubo#5026
The
interface-ipfs-core
mfs ls command tests seem to be based on the go implementation's behaviour but I'd like to know if the below was intentional.If you
ipfs.files.ls('/directory')
you get this sort of structure back:If you
ipfs.files.ls('/directory', {l: true})
, you get:In the first example you get
type: 0, size: 0, hash: ''
which look like they should be omitted from the response.In the second, the
type
field has a numeric value instead offile
ordirectory
which conflicts with the spec.Also, has anyone got an opinion about having
long
be the option field name instead ofl
? Seems a bit more self-explanatory.The text was updated successfully, but these errors were encountered: