### Basic Usage Examples Source: https://turkananation.github.io/swissarmyknife/getting-started Demonstrates string manipulation, type conversion, and Option usage. ```dart final title = 'release_candidate'.toTitleCase(); final number = '42'.toIntOrNull(); final maybeUser = Option.fromNullable('Ada'); print(title); print(number); print(maybeUser.map((name) => name.toUpperCase()).getOrElse('UNKNOWN')); ``` -------------------------------- ### Install SwissArmyKnife Source: https://turkananation.github.io/swissarmyknife/getting-started Add the dependency to your pubspec.yaml and fetch the package. ```yaml dependencies: swissarmyknife: ^0.1.0 ``` ```bash dart pub get ``` -------------------------------- ### Verify Release Source: https://turkananation.github.io/swissarmyknife/release Run the verification tool to ensure the release gate passes before proceeding. ```bash dart pub get dart run tool/agent/verify.dart release ``` -------------------------------- ### Configure Environment in Browser Source: https://turkananation.github.io/swissarmyknife/platform Use Env.fromMap for browser-based applications as Env.load is restricted to Dart VM platforms. ```dart Env.fromMap({ 'API_BASE_URL': 'https://api.example.com', }); ``` -------------------------------- ### Tag Release Source: https://turkananation.github.io/swissarmyknife/release Check the repository status and create a versioned tag to mark the release. ```bash git status --short git tag -a v0.1.0 -m "SwissArmyKnife v0.1.0" git push origin main git push origin v0.1.0 ``` -------------------------------- ### Basic Usage of SwissArmyKnife Utilities Source: https://turkananation.github.io/swissarmyknife Demonstrates common utility patterns including error handling with Result, string validation, and deep map access. ```dart import 'package:swissarmyknife/swissarmyknife.dart'; final parsed = Result.runCatching(() => int.parse('42')); final email = Validator.email().validate('team@example.com'); final name = {'user': {'name': 'Ada'}}.at('user.name').asStringOr('Unknown'); ``` -------------------------------- ### Publish Package Source: https://turkananation.github.io/swissarmyknife/release Publish the package to pub.dev after the tag workflow is successful and credentials are verified. ```bash dart pub publish ``` -------------------------------- ### Compose Middleware Pipeline Source: https://turkananation.github.io/swissarmyknife/cookbook Creates a processing pipeline by chaining tap and transform middleware functions. ```dart final pipeline = MiddlewarePipeline() .use(MiddlewarePipeline.tap((value) => print('in: $value'))) .use(MiddlewarePipeline.transform((value) => value + 1)); final output = await pipeline.run(41); ``` -------------------------------- ### Validate Input Source: https://turkananation.github.io/swissarmyknife/cookbook Demonstrates chaining validation rules and checking for failure results. ```dart final validator = Validator.email().minLength(5); final result = validator.validate('team@example.com'); if (result.isFailure) { print(result.errorOrNull); } ``` -------------------------------- ### Import SwissArmyKnife Source: https://turkananation.github.io/swissarmyknife/getting-started Use the single public barrel import to access all library features. ```dart import 'package:swissarmyknife/swissarmyknife.dart'; ``` -------------------------------- ### Parse Safely with Result Source: https://turkananation.github.io/swissarmyknife/cookbook Uses Result.runCatching to handle potential parsing errors and provide a fallback value. ```dart final port = Result.runCatching(() => int.parse('8080')) .map((value) => value.clamp(1, 65535)) .getOrElse(3000); ``` -------------------------------- ### Read JSON with Path Access Source: https://turkananation.github.io/swissarmyknife/cookbook Accesses nested JSON values using dot-notation paths with a default fallback. ```dart final payload = { 'user': {'profile': {'name': 'Ada'}}, }; final name = payload.at('user.profile.name').asStringOr('Unknown'); ``` -------------------------------- ### Bound Concurrency with TaskQueue Source: https://turkananation.github.io/swissarmyknife/cookbook Limits the number of concurrent operations using a TaskQueue. ```dart final queue = TaskQueue(concurrency: 4); final futures = ids.map((id) => queue.add(() => loadRecord(id)).future); final records = await Future.wait(futures); ``` -------------------------------- ### Retry Asynchronous Work Source: https://turkananation.github.io/swissarmyknife/cookbook Executes an asynchronous function with configurable retry attempts and exponential backoff. ```dart final result = await retry( () async => fetchSomething(), maxAttempts: 3, delay: const Duration(milliseconds: 200), backoff: BackoffStrategy.exponential, ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.