| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3335,7 +3335,8 @@ <h2 id="subcommands">Subcommands<a class="headerlink" href="#subcommands" title= | |||
| 3335 | 3335 | <ul> | |
| 3336 | 3336 | <li><code>pn init [name]</code>: scaffold a new project (creates <code>app/</code>, | |
| 3337 | 3337 | <code>pythonnative.toml</code>, <code>.gitignore</code>). With a name it creates <code>./<name>/</code> | |
| 3338 | - and scaffolds into it; without one it uses the current directory. | ||
| 3338 | + and scaffolds into it; the name must match <code>^[a-z][a-z0-9_-]*$</code>. | ||
| 3339 | + Without one it uses the current directory, whatever it's called. | ||
| 3339 | 3340 | Flag: <code>--force</code> to overwrite existing files or scaffold into a | |
| 3340 | 3341 | non-empty directory. See <a href="../../guides/configuration/">Configuration</a>.</li> | |
| 3341 | 3342 | <li><code>pn doctor [android|ios]</code>: diagnose the local toolchain and validate | |
@@ -3586,9 +3587,16 @@ <h2 id="pythonnative.cli.pn.init_project" class="doc doc-heading"> | |||
| 3586 | 3587 | one, it scaffolds into the current directory and names the project after | |
| 3587 | 3588 | it. Either way it writes <code>app/main.py</code>, <code>pythonnative.toml</code>, and | |
| 3588 | 3589 | <code>.gitignore</code>.</p> | |
| 3589 | - <p>The name has to be a single directory name, so the project always lands | ||
| 3590 | - inside the current directory. Anything that reads as a path, such as | ||
| 3591 | - <code>a/b</code>, <code>..</code>, or <code>/tmp/app</code>, is refused, and so is a name that | ||
| 3590 | + <p>A name you pass has to match <code>^[a-z][a-z0-9_-]*$</code>: lowercase letters, | ||
| 3591 | + digits, <code>-</code>, and <code>_</code>, starting with a letter. Anything else is | ||
| 3592 | + refused with a legal suggestion. That keeps the directory name and the | ||
| 3593 | + <code>name</code> field in the generated config identical, in the same spirit as | ||
| 3594 | + <code>flutter create</code> and <code>cargo new</code>. The name taken from the current | ||
| 3595 | + directory when you pass none is used as-is, so an existing directory | ||
| 3596 | + with any name still works.</p> | ||
| 3597 | + <p>The name also has to be a single directory name, so the project always | ||
| 3598 | + lands inside the current directory. Anything that reads as a path, such | ||
| 3599 | + as <code>a/b</code>, <code>..</code>, or <code>/tmp/app</code>, is refused, and so is a name that | ||
| 3592 | 3600 | resolves somewhere else, such as a symlink to another directory.</p> | |
| 3593 | 3601 | <p>It won't scaffold into a target directory that already holds files, and it | |
| 3594 | 3602 | won't overwrite any of the three paths above; pass <code>--force</code> to override | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3241,19 +3241,21 @@ <h1 id="getting-started">Getting Started<a class="headerlink" href="#getting-sta | |||
| 3241 | 3241 | </span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>pn<span class="w"> </span>--help | |
| 3242 | 3242 | </span></code></pre></div> | |
| 3243 | 3243 | <h2 id="create-a-project">Create a project<a class="headerlink" href="#create-a-project" title="Permanent link">¶</a></h2> | |
| 3244 | - <div class="language-bash highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>pn<span class="w"> </span>init<span class="w"> </span>MyApp | ||
| 3245 | - </span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="nb">cd</span><span class="w"> </span>MyApp | ||
| 3244 | + <div class="language-bash highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>pn<span class="w"> </span>init<span class="w"> </span>my_app | ||
| 3245 | + </span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="nb">cd</span><span class="w"> </span>my_app | ||
| 3246 | 3246 | </span></code></pre></div> | |
| 3247 | - <p>This creates a <code>MyApp/</code> directory containing:</p> | ||
| 3247 | + <p>This creates a <code>my_app/</code> directory containing:</p> | ||
| 3248 | 3248 | <ul> | |
| 3249 | 3249 | <li><code>app/</code> with a minimal <code>main.py</code></li> | |
| 3250 | 3250 | <li><code>pythonnative.toml</code>: your project configuration (app id, version, | |
| 3251 | 3251 | permissions, assets, and signing). See | |
| 3252 | 3252 | <a href="../guides/configuration/">Configuration</a>.</li> | |
| 3253 | 3253 | <li><code>.gitignore</code></li> | |
| 3254 | 3254 | </ul> | |
| 3255 | - <p>Run <code>pn init</code> without a name to scaffold into the current directory | ||
| 3256 | - instead, named after it.</p> | ||
| 3255 | + <p>A name has to be lowercase letters, digits, <code>-</code>, and <code>_</code>, starting with | ||
| 3256 | + a letter, so the directory name and the <code>name</code> field in the generated | ||
| 3257 | + config stay identical. Run <code>pn init</code> without a name to scaffold into the | ||
| 3258 | + current directory instead, named after it; that name is used as-is.</p> | ||
| 3257 | 3259 | <p>A minimal <code>app/main.py</code> looks like:</p> | |
| 3258 | 3260 | <div class="language-python highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kn">import</span><span class="w"> </span><span class="nn">pythonnative</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">pn</span> | |
| 3259 | 3261 | </span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a> | |
@@ -3304,8 +3306,8 @@ <h2 id="configure-your-app">Configure your app<a class="headerlink" href="#confi | |||
| 3304 | 3306 | splash, third-party packages, and signing) lives in a single | |
| 3305 | 3307 | <code>pythonnative.toml</code> at the project root:</p> | |
| 3306 | 3308 | <div class="language-toml highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="k">[app]</span> | |
| 3307 | - </span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a><span class="n">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"com.example.myapp"</span> | ||
| 3308 | - </span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"myapp"</span> | ||
| 3309 | + </span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a><span class="n">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"com.example.my_app"</span> | ||
| 3310 | + </span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"my_app"</span> | ||
| 3309 | 3311 | </span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a><span class="n">display_name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"My App"</span> | |
| 3310 | 3312 | </span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a><span class="n">version</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"1.0.0"</span> | |
| 3311 | 3313 | </span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a><span class="n">build</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3003,6 +3003,17 @@ | |||
| 3003 | 3003 | </span> | |
| 3004 | 3004 | </a> | |
| 3005 | 3005 | ||
| 3006 | + </li> | ||
| 3007 | + | ||
| 3008 | + <li class="md-nav__item"> | ||
| 3009 | + <a href="#invalid-project-name-myapp" class="md-nav__link"> | ||
| 3010 | + <span class="md-ellipsis"> | ||
| 3011 | + | ||
| 3012 | + Invalid project name: 'MyApp' | ||
| 3013 | + | ||
| 3014 | + </span> | ||
| 3015 | + </a> | ||
| 3016 | + | ||
| 3006 | 3017 | </li> | |
| 3007 | 3018 | ||
| 3008 | 3019 | <li class="md-nav__item"> | |
@@ -3461,6 +3472,17 @@ | |||
| 3461 | 3472 | </span> | |
| 3462 | 3473 | </a> | |
| 3463 | 3474 | ||
| 3475 | + </li> | ||
| 3476 | + | ||
| 3477 | + <li class="md-nav__item"> | ||
| 3478 | + <a href="#invalid-project-name-myapp" class="md-nav__link"> | ||
| 3479 | + <span class="md-ellipsis"> | ||
| 3480 | + | ||
| 3481 | + Invalid project name: 'MyApp' | ||
| 3482 | + | ||
| 3483 | + </span> | ||
| 3484 | + </a> | ||
| 3485 | + | ||
| 3464 | 3486 | </li> | |
| 3465 | 3487 | ||
| 3466 | 3488 | <li class="md-nav__item"> | |
@@ -3851,6 +3873,17 @@ <h3 id="refusing-to-treat-a-path-as-a-project-name-app"><code>Refusing to treat | |||
| 3851 | 3873 | lands inside the current directory. Pass a plain name like <code>my_app</code>, or | |
| 3852 | 3874 | <code>cd</code> to the directory you want the project in and run <code>pn init</code> with no | |
| 3853 | 3875 | name at all. <code>--force</code> doesn't lift this one.</p> | |
| 3876 | + <h3 id="invalid-project-name-myapp"><code>Invalid project name: 'MyApp'</code><a class="headerlink" href="#invalid-project-name-myapp" title="Permanent link">¶</a></h3> | ||
| 3877 | + <p>A name you pass to <code>pn init</code> has to match <code>^[a-z][a-z0-9_-]*$</code>: lowercase | ||
| 3878 | + letters, digits, <code>-</code>, and <code>_</code>, starting with a letter. That's the same | ||
| 3879 | + spirit as <code>flutter create</code> and <code>cargo new</code>, and it keeps the directory | ||
| 3880 | + name and the <code>name</code> field in the config identical. The error suggests a | ||
| 3881 | + legal name you can paste straight back, so <code>MyApp</code> suggests <code>myapp</code> and | ||
| 3882 | + <code>my app</code> suggests <code>my_app</code>. <code>--force</code> doesn't lift this one.</p> | ||
| 3883 | + <p>This applies only to a name you type. <code>pn init</code> with no name takes the | ||
| 3884 | + current directory's name as-is, so a directory called <code>MyProject</code> is | ||
| 3885 | + fine. To use a display name outside this set, edit <code>display_name</code> in | ||
| 3886 | + <code>pythonnative.toml</code> after scaffolding.</p> | ||
| 3854 | 3887 | <h3 id="refusing-to-scaffold-through-a-link-or-outside-the-current-directory-link"><code>Refusing to scaffold through a link or outside the current directory: link</code><a class="headerlink" href="#refusing-to-scaffold-through-a-link-or-outside-the-current-directory-link" title="Permanent link">¶</a></h3> | |
| 3855 | 3888 | <p>The name resolves somewhere other than a directory directly inside the | |
| 3856 | 3889 | current one, so <code>pn init</code> stops rather than writing through it. A symlink | |
| Back | FazBrowse Home | New Git URL |
0 commit comments