Skip to content

Implement a mode to exclude directories defined with arguments#36

Merged
ishkawa merged 4 commits intoishkawa:masterfrom
takasek:exclude_mode
Feb 11, 2018
Merged

Implement a mode to exclude directories defined with arguments#36
ishkawa merged 4 commits intoishkawa:masterfrom
takasek:exclude_mode

Conversation

@takasek
Copy link
Copy Markdown
Contributor

@takasek takasek commented Feb 11, 2018

resolve #35

I'm sorry but I don't find how to test the command.

Copy link
Copy Markdown
Owner

@ishkawa ishkawa left a comment

Choose a reason for hiding this comment

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

Basically, looks good to me!
I've left some comments, please confirm them.

Comment thread Sources/dikitgen/main.swift Outdated
}
} catch {
print("error: invalid arguments", to: &standardError)
print("usage: dikitgen <path to source code directory> [--exclude <subpaths to exclude>...]", to: &standardError)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good documentation 👍

This part ofmode(from:) function seems to assume --exclude DIR appears only once .
If it is right, ... doesn't express its behavior correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It accepts multiple directories (like --exclude Example Tests)
What stlye do you think is appropriate to represent it?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Oh, I misunderstood this 🙇

I think it's better to specify --exclude for each exclusions like --exclude DIR1 --exclude DIR2, because the meaning is clearer especially when we have more options in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I got it. I’m going to fix to the style!

Comment thread Sources/DIGenKit/CodeGenerator.swift Outdated

private func files(atPath path: String) -> [File] {
private func files(atPath path: String, excluding exclusions: [String]) -> [File] {
let exclusionsHavingSlash = exclusions.map { $0.last == "/" ? $0 : $0 + "/" }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nit: Shadowing exclusions prevents from accessing original exclusion accidentally.

let exclusions = exclusions.map { $0.last == "/" ? $0 : $0 + "/" }

@ishkawa
Copy link
Copy Markdown
Owner

ishkawa commented Feb 11, 2018

👍

I'll consider how we test CLI options later.
Anyway, this is a great first step!
Thank you @takasek.

@ishkawa ishkawa merged commit 3632c99 into ishkawa:master Feb 11, 2018
@takasek takasek deleted the exclude_mode branch February 11, 2018 14:40
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.

Ignore Carthage/Checkouts/DIKit

2 participants