cli icon indicating copy to clipboard operation
cli copied to clipboard

Use slice.source_path in RubyFileWriter

Open cllns opened this issue 1 year ago • 1 comments

If we can pass an actual slice instance into RubyFileWriter#directory, we could use our new Slice#source_path to make this simpler:

base = slice.source_path

This returns the appropriate value for both the app as well as slices, so it means we no longer need if app else slice conditionals everywhere, which has been a bother for the longest time :)

(Again, this would be another great refactor for post-merge, I don't want to hold anything up!)

Originally posted by @timriley in https://github.com/hanami/cli/pull/186#discussion_r1676984531

cllns avatar Jul 14 '24 01:07 cllns

When doing this, might be worth trying this other refactor for RubyFileWriter

Like you mentioned in the description, this is an internal class only so we can tolerate some slightly less ergonomic API design, but I think a refactor to allow a FileWriter instance to be initialised once and then used to write multiple files might be nice.

So this would probably pull the fs: and inflector: params out into #initialize, with the rest going into some method that writes an actual file.

I think this'd be worth playing with sometime, but it's not blocking and I'm definitely keen to get our full range of CLI commands ready for beta1 on Tuesday. So happy if this comes in a follow-up change of some kind :)

Originally posted by @timriley in https://github.com/hanami/cli/pull/199#discussion_r1676987192

cllns avatar Jul 14 '24 02:07 cllns

Closed in #222 (though I actually didn't end up doing what this issue says)

cllns avatar Jan 10 '25 22:01 cllns