Closed Sherlouk closed 6 years ago
Would it make sense to add a whole new flag (if so any naming preferences) or use something like --output-file -
where -
indicates stdout. I've seen this convention used before plutil
is an example of using this for stdout and paste
is an example of using -
for stdin.
I think an extra flag incase you want to output to a file and print out the result to the console. How about --output-console
?
In not sure how the UI looks to print to stdout and not a file. The use case of outputting to a file and stdout seems like it should be handled with something like tee
That's the bit I'm struggling with at the moment too. If --output-file -
is a paradigm then I can do a PoC
Seems reasonable to start and should be small to change
It seems that in Commandant, for --output-file -
it's expecting to extract a value:
guard index < oldArguments.count, case let .value(value) = oldArguments[index] else {
return .failure(missingArgumentError("--\(key)"))
}
And therefore we get a Missing argument for --output-file
Output:
(lldb) po arg
▿ --output-file
- key : "output-file"
(lldb) po oldArguments
▿ 2 elements
▿ 0 : --output-file
- key : "output-file"
▿ 1 : -
▿ flag : OrderedSet<Character>
- values : 0 elements
(lldb) po index
1
(lldb) po oldArguments.count
2
(lldb) po oldArguments[index]
▿ -
▿ flag : OrderedSet<Character>
- values : 0 elements
RawArgument does support flags, but the value it's consuming needs to be a boolean
If you can’t do the -
thing then maybe just have a Boolean flag that uses stdout and overrides (read ignores) output-file
I think the best solution here would be to remove the ability for the tool to output to a file, and we can let the user direct stdout to wherever they want.
e.g.
guise generate > $PROJECT_DIR/API.swift
There might be cases where a client would like to handle the output themselves and do something different. So we should allow the ability to not provided a save path, and instead just output to console.