From 82c45153c238d97ecdb1fd740a3c840b1163dc7b Mon Sep 17 00:00:00 2001 From: Harjot Gill Date: Tue, 1 Aug 2023 13:54:18 -0700 Subject: [PATCH] update prompts (#409) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Summary by CodeRabbit **New Feature:** - Introduced a `Mobile` struct in `mobile.go` that represents a mobile device with methods to control its operations and battery status. **Documentation:** - Updated instructions in `src/prompts.ts` for providing replacement code suggestions during code reviews, enhancing clarity and precision. > 🎉 Here's to the code that now shines bright, > A mobile struct brought to light. > With power on, off, and usage in sight, > And battery charge to last the night. 📱 > > Instructions updated, clear as day, > For code review suggestions, leading the way. > Celebrate this PR, hip hip hurray! 🥳 --- dist/index.js | 17 +++++----- mobile.go | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/prompts.ts | 17 +++++----- 3 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 mobile.go diff --git a/dist/index.js b/dist/index.js index 1c2c43c3..c214e43e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6842,14 +6842,15 @@ format \`\`. in the fenced code blocks. These snippets may be added to a different file (e.g. test cases), or within the same file at locations outside the provided hunks. Multiple new code snippets are allowed within a single review section. -- If needed, provide replacement code suggestions to fix the issues by using - fenced code blocks with the \`suggestion\` as the language identifier. The - line number range must map exactly to the range (inclusive) that needs to - be replaced within a new hunk. For instance, if 2 lines of code in a hunk - need to be replaced with 15 lines of code, the line number range must be - those exact 2 lines. You must replace all the lines in the range with your - suggestion. Replacement suggestions must be complete, correctly - formatted/indented and without the line number annotations. +- If needed, provide replacement code to fix the issues by using fenced code + blocks with the \`suggestion\` or the \`diff\` as the language identifier/format, + depending on whether the suggestion is a few lines of code (~15 lines) or + a larger diff (> 15 lines) respectively. The line number range must map + exactly to the range (inclusive) that needs to be replaced within a new hunk. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of + code, the line number range must be those exact 2 lines. You must replace all + the lines in the range with your suggestion. Replacement suggestions must be complete, + correctly formatted/indented and without the line number annotations. - If there are no issues found on a line range, you MUST respond with the text \`LGTM!\` for that line range in the review section. - Reflect on your comments and line number ranges before sending the final diff --git a/mobile.go b/mobile.go new file mode 100644 index 00000000..befc75a8 --- /dev/null +++ b/mobile.go @@ -0,0 +1,91 @@ +package main + +import ( + "fmt" + "time" +) + +// Mobile struct represents a mobile device. +type Mobile struct { + Brand string + Model string + IsOn bool + Battery int + LastUsage time.Time +} + +// TurnOn turns on the mobile device. +func (m *Mobile) TurnOn() { + m.IsOn = true + m.LastUsage = time.Now() + fmt.Printf("%s %s is now turned on.\n", m.Brand, m.Model) +} + +// TurnOff turns off the mobile device. +func (m *Mobile) TurnOff() { + m.IsOn = false + fmt.Printf("%s %s is now turned off.\n", m.Brand, m.Model) +} + +// UseMobile simulates the usage of the mobile device. +func (m *Mobile) UseMobile(minutes int) { + if !m.IsOn { + fmt.Println("Please turn on the mobile device first.") + return + } + + if m.Battery <= 0 { + fmt.Println("The mobile device is out of battery. Please charge it.") + return + } + + m.LastUsage = time.Now() + fmt.Printf("Using %s %s for %d minutes.\n", m.Brand, m.Model, minutes) + + // Simulate battery drain + m.Battery -= minutes + if m.Battery < 0 { + m.Battery = 0 + } + + // Check battery level + if m.Battery == 0 { + m.TurnOff() + fmt.Println("The mobile device is out of battery. Please charge it.") + } +} + +// ChargeMobile charges the mobile device. +func (m *Mobile) ChargeMobile(minutes int) { + m.LastUsage = time.Now() + m.Battery += minutes + if m.Battery > 100 { + m.Battery = 100 + } + fmt.Printf("Charging %s %s for %d minutes.\n", m.Brand, m.Model, minutes) +} + +func main() { + // Create a new mobile device + myMobile := Mobile{ + Brand: "Apple", + Model: "iPhone X", + IsOn: false, + Battery: 50, + } + + // Turn on the mobile device + myMobile.TurnOn() + + // Simulate using the mobile device + myMobile.UseMobile(60) + + // Charge the mobile device + myMobile.ChargeMobile(30) + + // Simulate using the mobile device again + myMobile.UseMobile(120) + + // Turn off the mobile device + myMobile.TurnOff() +} diff --git a/src/prompts.ts b/src/prompts.ts index dc3c09f2..7300c054 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -168,14 +168,15 @@ format \`\`. in the fenced code blocks. These snippets may be added to a different file (e.g. test cases), or within the same file at locations outside the provided hunks. Multiple new code snippets are allowed within a single review section. -- If needed, provide replacement code suggestions to fix the issues by using - fenced code blocks with the \`suggestion\` as the language identifier. The - line number range must map exactly to the range (inclusive) that needs to - be replaced within a new hunk. For instance, if 2 lines of code in a hunk - need to be replaced with 15 lines of code, the line number range must be - those exact 2 lines. You must replace all the lines in the range with your - suggestion. Replacement suggestions must be complete, correctly - formatted/indented and without the line number annotations. +- If needed, provide replacement code to fix the issues by using fenced code + blocks with the \`suggestion\` or the \`diff\` as the language identifier/format, + depending on whether the suggestion is a few lines of code (~15 lines) or + a larger diff (> 15 lines) respectively. The line number range must map + exactly to the range (inclusive) that needs to be replaced within a new hunk. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of + code, the line number range must be those exact 2 lines. You must replace all + the lines in the range with your suggestion. Replacement suggestions must be complete, + correctly formatted/indented and without the line number annotations. - If there are no issues found on a line range, you MUST respond with the text \`LGTM!\` for that line range in the review section. - Reflect on your comments and line number ranges before sending the final