Publish works on entire packages (a Cargo.toml defines a package). If you want to publish one and not the other, you will have to split your package into two packages (possibly in a workspace).
That said, the error you received sounds like you have a syntax error in your Cargo.toml or something. What are the contents of your Cargo.toml and what command did you run?
Thank you to lead me to inspect the Cargo.toml thoroughly.
The problem was in Cargo.toml "keywords".
I had spaces in the string and that is not allowed.
My content were:
keywords = ["Rust cli and library project"]
Note: crates.io has a maximum of 5 keywords.
Each keyword must be ASCII text, start with a letter,
and only contain letters, numbers, _ or -,
and have at most 20 characters.