1"use strict";(self.webpackChunkkcl_website=self.webpackChunkkcl_website||[]).push([[3038],{3905:(e,n,t)=>{t.d(n,{Zo:()=>m,kt:()=>u});var a=t(67294);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function l(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?r(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function o(e,n){if(null==e)return{};var t,a,i=function(e,n){if(null==e)return{};var t,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)t=r[a],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)t=r[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var c=a.createContext({}),p=function(e){var n=a.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},m=function(e){var n=p(e.components);return a.createElement(c.Provider,{value:n},e.children)},d="mdxType",s={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},k=a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,r=e.originalType,c=e.parentName,m=o(e,["components","mdxType","originalType","parentName"]),d=p(t),k=i,u=d["".concat(c,".").concat(k)]||d[k]||s[k]||r;return t?a.createElement(u,l(l({ref:n},m),{},{components:t})):a.createElement(u,l({ref:n},m))}));function u(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var r=t.length,l=new Array(r);l[0]=k;var o={};for(var c in n)hasOwnProperty.call(n,c)&&(o[c]=n[c]);o.originalType=e,o[d]="string"==typeof e?e:i,l[1]=o;for(var p=2;p<r;p++)l[p]=t[p];return a.createElement.apply(null,l)}return a.createElement.apply(null,t)}k.displayName="MDXCreateElement"},84241:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>s,frontMatter:()=>r,metadata:()=>o,toc:()=>p});var a=t(87462),i=(t(67294),t(3905));const r={},l="kcl mod init",o={unversionedId:"tools/cli/package-management/command-reference/init",id:"version-0.12/tools/cli/package-management/command-reference/init",title:"kcl mod init",description:"Init a kcl module.",source:"@site/versioned_docs/version-0.12/tools/cli/package-management/command-reference/1.init.md",sourceDirName:"tools/cli/package-management/command-reference",slug:"/tools/cli/package-management/command-reference/init",permalink:"/docs/tools/cli/package-management/command-reference/init",draft:!1,editUrl:"https://github.com/kcl-lang/kcl-lang.io/tree/main/versioned_docs/version-0.12/tools/cli/package-management/command-reference/1.init.md",tags:[],version:"0.12",lastUpdatedBy:"Peefy",lastUpdatedAt:1776150960,formattedLastUpdatedAt:"Apr 14, 2026",sidebarPosition:1,frontMatter:{},sidebar:"tools",previous:{title:"Validation",permalink:"/docs/tools/cli/kcl/vet"},next:{title:"kcl mod add",permalink:"/docs/tools/cli/package-management/command-reference/add"}},c={},p=[{value:"Usage",id:"usage",level:2},{value:"Description",id:"description",level:2},{value:"Options",id:"options",level:2},{value:"--help, -h",id:"--help--h",level:3},{value:"Examples",id:"examples",level:2},{value:"Init the current directory into a kcl package",id:"init-the-current-directory-into-a-kcl-package",level:3},{value:"Init a kcl package with a name",id:"init-a-kcl-package-with-a-name",level:3},{value:"Reference",id:"reference",level:2}],m={toc:p},d="wrapper";function s(e){let{components:n,...t}=e;return(0,i.kt)(d,(0,a.Z)({},m,t,{components:n,mdxType:"MDXLayout"}),(0,i.kt)("h1",{id:"kcl-mod-init"},"kcl mod init"),(0,i.kt)("p",null,"Init a kcl module."),(0,i.kt)("h2",{id:"usage"},"Usage"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-shell"},"kcl mod init [options][module_name]\n")),(0,i.kt)("h2",{id:"description"},"Description"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"kcl mod init")," will initialize a kcl package in the current directory. If the package name is not provided, the name of the current directory will be used."),(0,i.kt)("p",null,"If the package name is provided, a subdirectory with the name of the package will be created and the package will be initialized in that directory."),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"kcl mod init")," will create ",(0,i.kt)("inlineCode",{parentName:"p"},"kcl.mod"),", ",(0,i.kt)("inlineCode",{parentName:"p"},"kcl.mod.lock")," and ",(0,i.kt)("inlineCode",{parentName:"p"},"main.k")," under the package directory."),(0,i.kt)("h2",{id:"options"},"Options"),(0,i.kt)("h3",{id:"--help--h"},"--help, -h"),(0,i.kt)("p",null,"Show help for ",(0,i.kt)("inlineCode",{parentName:"p"}
1,"kcl mod init")," command."),(0,i.kt)("h2",{id:"examples"},"Examples"),(0,i.kt)("h3",{id:"init-the-current-directory-into-a-kcl-package"},"Init the current directory into a kcl package"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-shell"},"# create an empty directory\nmkdir my_package\n\n# cd into the directory\ncd my_package\n\n# init the current directory into a kcl package\nkcl mod init\n")),(0,i.kt)("h3",{id:"init-a-kcl-package-with-a-name"},"Init a kcl package with a name"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-shell"},"# init a kcl package with a name 'my_package'\nkcl mod init my_package\n")),(0,i.kt)("h2",{id:"reference"},"Reference"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-shell"},"This command initializes new kcl module in current directory.\n\nUsage:\n kcl mod init [flags]\n\nExamples:\n kcl mod init <command> [arguments]...\n # Init one kcl module with the current folder name\n kcl mod init\n\n # Init one kcl module with the name\n kcl mod init package-name\n\n # Init one kcl module with the name and version\n kcl mod init package-name --version 0.1.0\n\nFlags:\n -h, --help help for init\n --version string init module version\n\nGlobal Flags:\n -q, --quiet Set the quiet mode (no output)\n")))}s.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.