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

Add quiet option #167

Merged
merged 2 commits into from
Nov 23, 2017
Merged

Add quiet option #167

merged 2 commits into from
Nov 23, 2017

Conversation

soffes
Copy link
Contributor

@soffes soffes commented Nov 22, 2017

This option will suppress success messages. A new Logger struct is added to the XcodeGen target that encapsulates printing, exiting, and the Rainbow logic.

I only added a Commander flag for --quiet. If we added a Commander interface, it would be trivial to remove colored output too if that is desired. I didn't do this since I couldn't decide on a name. Also, I figured if you were in a situation where you didn't want colored output, you might also want to suppress emojis.

Copy link
Owner

@yonaskolb yonaskolb left a comment

Choose a reason for hiding this comment

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

Thanks @soffes! Looks good. I didn't think that people might not want the summary output 😄
Personally I use the include feature to bring together many different partial spec files, so it's useful to see what actually ended up in the final spec.

If we added a --verbose option later, that would probably fight with --quite. Maybe it's even worth locking the current output behind a verbose flag. What do you think? I would like to keep the current output as default though. Is it just annoying or are there technical considerations for removing it?


// MARK: - Properties

/// Should success messages be suppressed
Copy link
Owner

Choose a reason for hiding this comment

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

Seems it suppresses info not success messages

}
}

command(
Option<String>("spec", "project.yml", flag: "s", description: "The path to the spec file"),
Option<String>("project", "", flag: "p", description: "The path to the folder where the project should be generated"),
generate)
.run(version)
Flag("quiet", flag: "q", description: "Suppress printing of success messages", default: false),
Copy link
Owner

Choose a reason for hiding this comment

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

Seems it suppresses info not success messages

/// - parameter message: the message to log
func success(_ message: String) -> Never {
print(isColored ? message.green : message)
exit(0)
Copy link
Owner

Choose a reason for hiding this comment

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

We might print multiple success messages. No need to exit here

@yonaskolb
Copy link
Owner

Could you add documentation to Readme as well?

// XcodeGen
//
// Created by Sam Soffes on 11/21/17.
//
Copy link
Owner

Choose a reason for hiding this comment

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

Could you remove header. I've removed them all in master, and they are all removed automatically now in make format_code

@soffes
Copy link
Contributor Author

soffes commented Nov 22, 2017

Made the changes your requested! I tested this locally since there aren't tests for the output of the command line tool (yet!).

I was thinking about --verbose too. Maybe this option down the road could list all of the targets, groups, files etc. This may be useful for debugging at some point.

/// - parameter message: the message to log
func fatal(_ message: String) -> Never {
print(isColored ? message.red : message)
exit(1)
Copy link
Contributor

@sbarow sbarow Nov 22, 2017

Choose a reason for hiding this comment

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

Seems a bit weird to put this kind of logic in a Logger? You wouldn't really expect the program to exit after logging a fatal error, the user may want to do some extra cleanup after logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair. I was just excited to use -> Never. I'll remove. I agree it's weird for the logger to exit.

print("Parsing spec failed: \(error.description)".red)
exit(1)
logger.fatal("Parsing spec failed: \(error.description)")
exit(1)
Copy link
Owner

Choose a reason for hiding this comment

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

spacing :trollface:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every time I regenerate the Xcode project it changes it back to tabs 🙄


// MARK: - Logging

/// Log a fatal message and exit with status code 1
Copy link
Owner

Choose a reason for hiding this comment

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

This is why I stay away from doc comments as they always get out of date. 😄 In this case, it mentions status code here (and in success).
If this doesn't exit anymore, we could also rename this to error.

Also if we wanted to remove all the duplicate exit(1) in the main file, a simple helper function there called fatalError(_ message: String) could log an error and then exit

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for not seeing this before :)

Copy link
Contributor

Choose a reason for hiding this comment

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

fatalError(_ message: String) good use case for -> Never @soffes 😜

@yonaskolb yonaskolb merged commit f577eb7 into yonaskolb:master Nov 23, 2017
@soffes
Copy link
Contributor Author

soffes commented Nov 23, 2017

@yonaskolb thanks for your time on this! Sorry for all of the back and forth!

@yonaskolb
Copy link
Owner

Thank YOU :)

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.

3 participants