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

Clean up the App Struct #73

Open
ellnix opened this issue May 2, 2024 · 1 comment
Open

Clean up the App Struct #73

ellnix opened this issue May 2, 2024 · 1 comment

Comments

@ellnix
Copy link
Collaborator

ellnix commented May 2, 2024

re: @ellnix (from #71)

I suggest

  • Moving App to lib
  • Moving all the helper functions (functions that do not have a corresponding command) into App
  • Removing the functions that have commands corresponding to them from App and just having them as regular functions in main.rs (or as part of a Cli type)
  • Making the App constructor to take a single package_name parameter: let app = App::new("dev.CoCtus.coctus");

This would then separate the responsibility between calling the commands and the helper functions which we could use in tests. It would also prepare for #61 by allowing configuration to be stored in App and be used by users of the lib.

I've given this some thought and I think that it would be better to expose a simpler API that is completely agnostic of the coctus CLI tool and its data/config (that means keeping App private as its only purpose is to hold references to the configuration directories). Users of the library should have the choice of using their own config/data if they want to be independent of coctus the command line tool.

There are probably some methods in App that do "too much" though. Ideally they would follow this recipe (limiting I/O to the edges of the app):

  1. Doing I/O (reading args, environment variables and files)
  2. Passing the data forward to pure, easy-to-test functions (which we may want to expose in lib)
  3. Doing I/O (printing the output / errors)

Originally posted by @Andriamanitra in #70 (comment)

@ellnix
Copy link
Collaborator Author

ellnix commented May 2, 2024

Thought this might be better to track as an issue.

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

No branches or pull requests

1 participant