Skip to content

feat: create standalone CLI for cocoindex #485

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

Merged
merged 8 commits into from
May 20, 2025

Conversation

lemorage
Copy link
Contributor

This is a breaking change, and may resolve #417.

We create a standalone CLI for cocoindex. For compatibility reasons, we mark main_fn as deprecated. So, users can still use @cocoindex.main_fn() in their programs, but when running python main.py cocoindex <command>, the deprecation warning will be shown instead.

Now, in the new CLI, we will use cocoindex <command> [options] --app main.py to run the CLI program directly.

A lot of examples and docs will then be outdated and need to be updated accordingly. I will start on those if all the changes in this PR are confirmed.

@badmonster0
Copy link
Member

Really awesome! Thanks for making this happen!

Copy link
Member

@badmonster0 badmonster0 left a comment

Choose a reason for hiding this comment

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

Another thing I just notice - which will be needed by migrating existing examples - is about loading of the .env files.

Previously they're loaded by examples' main module (under the if __name__ == "__main__": condition), but they're no longer executed when we invoke this standalone CLI.

So I think this standalone CLI may need to be able to load .env file, and we may also add a --env_file flag to allow override (example: flask CLI is doing the similar).

Let me know if you have any other thoughts. Thanks!

@lemorage
Copy link
Contributor Author

Nice catch!

Copy link
Member

@badmonster0 badmonster0 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for making it happen! This is a big thing!

@lemorage
Copy link
Contributor Author

Thanks for all the help along the way! I've created another PR accounting for the docs' changes to the standalone CLI.

@badmonster0 badmonster0 merged commit 93b34e5 into cocoindex-io:main May 20, 2025
6 checks passed
chardoncs pushed a commit to chardoncs/cocoindex that referenced this pull request May 21, 2025
* feat(flow): update text label to handle empty lines instead of color style

* feat: update to use standalone cocoindex cli

* feat: pass in `<module_path>:<flow_name>` directly in new CLI

* feat: only show relevant flows given ls targets

* feat: add function to parse app target and warn on flow name usage

* feat: add support for loading dot-env files

* feat: use `find_dotenv` for better path resolution
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.

[FEATURE] Create standalone cocoindex CLI
2 participants