class Start: banner = Steps( Box("Bento Initialization"), Echo( Text( "Bento configures itself for personal use by default. This means that it:", processor=Processors.wrap(), ) ), Newline(), Echo( Text( "1. Automatically checks for issues introduced by your code, as you commit it", processor=Processors.wrap(), ) ), Echo( Text( "2. Only affects you; it won’t change anything for other project contributors", processor=Processors.wrap(), ) ), Newline(), Echo( Text( "Learn more about personal and team use at bento.dev/workflows.", processor=Processors.wrap_link( [Link("bento.dev/workflows", "https://bento.dev/workflows")] ), ) ), Newline(), ) confirm = Steps(Confirm("Press ENTER to add Bento to this project"), Newline())
class SuggestAutocomplete: confirm = Confirm( Text( "Bento supports tab autocompletion. Do you want to add it to your shell profile now?", processor=Processors.wrap(), ), options={"default": True}, ) install = Progress( content=Multi([ "Adding autocompletion to ", Sub(0, style={ "bold": True, "dim": True }) ]), extra=12, ) confirm_yes = Newline() confirm_no = Echo( Multi([ "\nTo enable autocompletion later, run $ ", Text("bento enable autocomplete", style={"bold": True}), ".\n", ]))
class ConfirmTos: fresh = Steps( Echo( Multi( [ "Privacy: ", Text( "We take privacy seriously. Bento runs exclusively on your computer. It will never send your " "code anywhere.", style={"dim": True}, ), ], processor=Processors.wrap(extra=8), ) ), Newline(), Echo( Text( "We’re constantly looking to make Bento better. To that end, we collect limited usage and results " "data. To learn more, see bento.dev/privacy.", processor=Processors.wrap_link( [Link("bento.dev/privacy", "https://bento.dev/privacy")] ), style={"dim": True}, ) ), Newline(), ) invalid_version = Error( "~/.bento/config.yml is malformed. Please remove this file and re-run Bento. " ) upgrade = Steps( Echo( Text( "We've made changes to our terms of service. Please review the new terms. If you have any questions " "or concerns please reach out via [email protected].", processor=Processors.wrap_link( [Link("*****@*****.**", "mailto:[email protected]")] ), style={"dim": True}, ) ), Newline(), ) prompt = Confirm( "Continue and agree to Bento's terms of service and privacy policy?", options={"default": True}, ) error = Error( "Bento did NOT install. Bento beta users must agree to the terms of service to continue. Please reach out to " "us at [email protected] with questions or concerns. " )
class InstallAutorun: install = Progress( Multi( [ "Enabling autorun (see $ ", Text("bento enable autorun --help", style={"dim": True, "bold": True}), Text(")", style={"dim": True}), ] ), extra=20, )
class Install: learn_more = Text( "To learn more, see the README.", processor=Processors.wrap_link([ Link( "README", "https://github.com/returntocorp/bento/blob/master/README.md#running-in-cicd", ) ]), ) banner = Steps( Echo( Multi( [ "Configuring a GitHub Action to automatically check your team's pull requests. ", learn_more, ], processor=Processors.wrap(), )), Newline(), ) progress = Progress( content=Multi([ "Creating GitHub Action configuration at ", Sub(0, style={ "bold": True, "dim": True }), Text("/", style={ "bold": True, "dim": True }), ]), extra=24, ) after_progress = Newline() finalize_ci = Steps( Warn("To finalize configuration of Bento's GitHub Action, please:"), Echo( Multi([ " $ git add .github/\n", ' $ git commit -m "Add Bento GitHub Action"\n', " $ git push\n", ])), )
class UpdateEmail: leader = Steps( Echo( Multi( [ "Registration: ", Text( "We’ll use your email to provide support and share product updates. You can unsubscribe at " "any time.", style={"dim": True}, ), ], processor=Processors.wrap(extra=8), ) ), Newline(), ) prompt = Prompt("What is your email address?") failure = Steps( Newline(), Warn( "We were unable to subscribe you to the Bento mailing list (which means you may miss out on " "announcements!). Bento will continue running. Please shoot us a note via [email protected] to debug. " ), )
class Finish: body = Steps( Box("Thank You"), Echo( Text( "From all of us at r2c, thank you for trying Bento! We can’t wait to hear what you think.", processor=Processors.wrap(), )), Newline(), Echo( Multi( [ "Help and feedback: ", Text("Reach out to us at ", style={"dim": True}), "*****@*****.**", Text(" or file an issue on ", style={"dim": True}), "GitHub", Text(". We’d love to hear from you!", style={"dim": True}), ], processor=Processors.wrap_link( [ Link("*****@*****.**", "mailto:[email protected]"), Link("GitHub", "https://github.com/returntocorp/bento/issues"), ], extra=16, ), )), Newline(), Echo( Multi( [ "Community: ", Text("Join ", style={"dim": True}), "#bento", Text( " on our community Slack. Get support, talk with other users, and share feedback.", style={"dim": True}, ), ], processor=Processors.wrap_link( [ Link( "#bento", "https://join.slack.com/t/r2c-community/shared_invite/enQtNjU0NDYzMjAwODY4LWE3NTg1MGNhYTAwMzk5ZGRhMjQ2MzVhNGJiZjI1ZWQ0NjQ2YWI4ZGY3OGViMGJjNzA4ODQ3MjEzOWExNjZlNTA", ) ], extra=16, ), )), Newline(), Echo("Go forth and write great code! To use Bento:"), Echo( Multi([ _step_item("commit code", "git commit"), _step_item("get help for a command", "bento [COMMAND] --help", nl=False), ])), )
def _step_item(desc: str, cmd: str, nl: bool = True) -> Content: """ Echoes desc․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․ $ cmd with styling. If 'nl' is False, does not emit a newline at the end of the line """ return Multi([ " ", Text(desc, processor=Processors.ljust(-40, "․"), style={"dim": True}), f" $ {cmd}\n", ])
) not_registered = Steps( Error("This installation of Bento is not registered."), Echo(""" Please either: ◦ Register Bento by running it in an interactive terminal ◦ Run Bento with `--agree --email [EMAIL]`"""), ) welcome = Steps( Box("Global Bento Configuration"), Echo( Text( "Thanks for installing Bento, a free and opinionated toolkit for gradually adopting linters and program " "analysis in your codebase!", processor=Processors.wrap(), )), Newline(), ) finalize = Newline() class UpdateEmail: leader = Steps( Echo( Multi( [ "Registration: ", Text(