On <kotlin new> in toolchain v 0.13 Having both `k...
# kotlin-toolchain
e
On kotlin new in toolchain v 0.13 Having both
kotlin init
and
kotlin new
for project scaffolding makes things messy. Now there are 2 different commands with the same purpose. The only difference I noticed is that
kotlin new
interactively asks for a root path, while
kotlin init
assumes current directory is the root path. The single command that interactively asks for a root path as a very first step would be much more clean and consistent, wouldn't it?
agree 2
j
Thanks a lot for the feedback! It's not exactly about interactive vs non-interactive.
new
can also take the path to the project to create, and will not ask interactively when you pass it (
kotlin new foo
).
init
's purpose is to generate files in an existing directory (similar to
git init
,
cargo init
, etc.). Semantically they are a bit different in intent. At the moment, it might seem a bit redundant, but we are considering building up on
init
so it can generate more granularly what you need after you already created a project. For instance, it could be
kotlin init wrappers
so it adds
kotlin
wrappers to an existing non-Kotlin Toolchain project, or
kotlin init git
, to generate git files and initialize a git repository, etc.
e
> it can generate more granularly what you need AFTER you already created a project Oh, now it makes sense. But still,
new
and
init
are considered as interchangeable words in the context of CLI, with meaning "create a new project". I think these 2 commands may confuse newcomers. At least this is my personal perception.
🙏 1
j
Yeah that is fair. I wonder if rust users suffer from this, as
cargo
also has this dual approach, without even some extra things under
init
. So does
poetry
for python
a
@evkaky could you please share how exactly you've encountered the confusion, like in which moment and what your thoughts were, like for instance I imagine something like: I invoked
kotlin --help
and saw 2 commands and it made me think this or that I'm curious to learn where the confusion comes from ps: thanks for the feedback, it's very valuable
➕ 1
s
That basically makes
kotlin new .
and
kotlin init
exactly the same, right? That does feel redundant. And it even looks like
kotlin new
has some check for this, as well, considering its output doesn't tell you to
cd
into the directory it was passed:
Copy code
~/tmp/existing
$ kotlin new .
Project successfully generated

Now you may build your project with:
  kotlin build
Or open the generated folder in an IDE with the Kotlin Toolchain plugin.

~/tmp/existing
$ cd ..

~/tmp
$ kotlin new generated
Project successfully generated

Now you may build your project with:
  cd generated && kotlin build
Or open the generated folder in an IDE with the Kotlin Toolchain plugin.
e
@Anton Prokhorov Originally my confusion came from the blog post. It says that
kotlin new
is offering an interactive setup flow
And I knew before that there is a
kotlin init
command that offers... an interactive setup flow. So the first reaction was "wow, they are absolutely the same" And I have to admit that even after seeing this description from
--help
output
Copy code
init - Initialize a Kotlin project in an existing directory (the current directory by default)

new - Create a Kotlin project in a new directory
I'm still confused. "initialise a project" and "create a project" are the same things to me. From the description the only difference between them I can outline is that the one of them is for creating a new project in a new directory, while the other - in the current/existing directory. So the natural question was why not merging them into a single command. Actually @joffrey's explanation was the only clear one to me, pointing what is the actual difference between those 2 commands.
👌🏻 1
🙏 1