From a30349f0dc7808bf85c2b82cf041dc08cce1b210 Mon Sep 17 00:00:00 2001 From: Thilan Date: Mon, 17 Mar 2025 09:55:46 +0530 Subject: [PATCH 1/4] edit content for readme.md for lib generation --- .../main/resources/new_cmd_defaults/README.md | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md index fc8b1b67c0a3..be83bb57ce11 100644 --- a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md +++ b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md @@ -1,5 +1,63 @@ -Prints "Hello, World!" with a hello function. -[//]: # (above is the package summary) - # Package Overview -Prints "Hello, World!" as the output to the command line using a hello function. + +This package provides a simple function to print "Hello, World!" to the command line. Additionally, you can provide a name to the function to print a personalized greeting. + +(Note: For this example, we are assuming the organization name is `user` and the package name is `socialMedia`.) + +## Functionality + +### hello Function + +```ballerina +public function hello(string? name) returns string { + if name !is () { + return string `Hello, ${name}`; + } + return "Hello, World!"; +} +``` + +## Build from Source and Publish + +### Build the Package + +To build the package, use the following command: + +```bash +bal pack +``` + +### Publish the Package + +To publish the package to a local repository, use the following command: + +```bash +bal push --repository=local +``` + +## Usage + +### Importing the Package + +```ballerina +import ballerina/io; +import user/socialMedia; +``` + +### Using the hello Function + +```ballerina +public function main() { + string greeting = socialMedia:hello("Ballerina"); + io:println(greeting); // Output: Hello, Ballerina +} +``` + +You can call the `hello` function without any arguments to get the default greeting: + +```ballerina +public function main() { + string greeting = socialMedia:hello(); + io:println(greeting); // Output: Hello, World! +} +``` From d8e5e8ac940a612e3bea29c46bfd0fc2e103df8b Mon Sep 17 00:00:00 2001 From: Thilan Date: Mon, 17 Mar 2025 10:20:11 +0530 Subject: [PATCH 2/4] Edit readme.md for lib gen --- .../main/resources/new_cmd_defaults/README.md | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md index be83bb57ce11..d5e170e11f32 100644 --- a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md +++ b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md @@ -1,12 +1,10 @@ # Package Overview -This package provides a simple function to print "Hello, World!" to the command line. Additionally, you can provide a name to the function to print a personalized greeting. - -(Note: For this example, we are assuming the organization name is `user` and the package name is `socialMedia`.) +The `user/socialMedia` package provides a simple utility function to print "Hello, World!" to the command line. Additionally, it supports personalized greetings by accepting an optional name parameter. ## Functionality -### hello Function +The `hello` function is the primary utility provided by this package. It accepts an optional `string` parameter and returns a greeting message as a `string`. ```ballerina public function hello(string? name) returns string { @@ -17,16 +15,26 @@ public function hello(string? name) returns string { } ``` +### Parameters + +- name (string?): An optional name to include in the greeting. If not provided, the default greeting is returned. + +### Returns + +- string: A greeting message, either personalized (e.g., "Hello, Ballerina") or the default "Hello, World!". + ## Build from Source and Publish ### Build the Package -To build the package, use the following command: +To build the package locally, execute the following command in the terminal: ```bash bal pack ``` +This command compiles the package and prepares it for use or distribution. + ### Publish the Package To publish the package to a local repository, use the following command: @@ -37,23 +45,20 @@ bal push --repository=local ## Usage -### Importing the Package +To use the user/socialMedia package in your Ballerina project, import it along with the ballerina/io module for output handling. +(Note: For this example, we are assuming the organization name is `user` and the package name is `socialMedia`.) ```ballerina import ballerina/io; import user/socialMedia; -``` -### Using the hello Function - -```ballerina public function main() { string greeting = socialMedia:hello("Ballerina"); io:println(greeting); // Output: Hello, Ballerina } ``` -You can call the `hello` function without any arguments to get the default greeting: +The `hello` function can be called without any arguments to get the default greeting: ```ballerina public function main() { From 1c92f84ed086b91823d3748792aa04b2cbf705a4 Mon Sep 17 00:00:00 2001 From: Thilan Dissanayaka <43875064+thil4n@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:19:30 +0530 Subject: [PATCH 3/4] Update cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md Co-authored-by: Asma Jabir --- cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md index d5e170e11f32..a32cb670cd32 100644 --- a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md +++ b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md @@ -1,6 +1,6 @@ # Package Overview -The `user/socialMedia` package provides a simple utility function to print "Hello, World!" to the command line. Additionally, it supports personalized greetings by accepting an optional name parameter. +This package provides a simple utility function to print "Hello, World!" to the command line. It also supports personalized greetings by optionally accepting a name. ## Functionality From b94d97172bf0681a08bd532b4f2b8b88e7ceacaa Mon Sep 17 00:00:00 2001 From: Thilan Date: Wed, 19 Mar 2025 11:41:28 +0530 Subject: [PATCH 4/4] Update README.md to remove outdated functionality details for user/socialMedia package --- .../main/resources/new_cmd_defaults/README.md | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md index a32cb670cd32..a8bf29d20133 100644 --- a/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md +++ b/cli/ballerina-cli/src/main/resources/new_cmd_defaults/README.md @@ -2,27 +2,6 @@ This package provides a simple utility function to print "Hello, World!" to the command line. It also supports personalized greetings by optionally accepting a name. -## Functionality - -The `hello` function is the primary utility provided by this package. It accepts an optional `string` parameter and returns a greeting message as a `string`. - -```ballerina -public function hello(string? name) returns string { - if name !is () { - return string `Hello, ${name}`; - } - return "Hello, World!"; -} -``` - -### Parameters - -- name (string?): An optional name to include in the greeting. If not provided, the default greeting is returned. - -### Returns - -- string: A greeting message, either personalized (e.g., "Hello, Ballerina") or the default "Hello, World!". - ## Build from Source and Publish ### Build the Package